// This class stores information about the player's status and methods to update it. public class Player { private int score, lines, level; // Initialization. public Player() { score = lines = level = 0; } // Get the value of the score. public int getScore() { return score; } // Add some amount of points to the score. public void addScore(int n) { score += n; } // Get the number of lines. public int getLines() { return lines; } // Get the current level. public int getLevel() { return level; } // Add some lines and adjust the score and level if appropriate. public void addLines(int n) { lines += n; // Calculate the score bonus based on number of lines and level. switch (n) { case 1: score += 40*(level+1); break; case 2: score += 100*(level+1); break; case 3: score += 300*(level+1); break; case 4: score += 1200*(level+1); break; } // Calculate the current level. level = 0; int tmp = lines; while (tmp > 9) { tmp -= 10; level++; } } }