/* cop3330 in class example * represents the score of a tetris player * a score is lines in tetris * also stored the level * * An example of inheritance. If PlayerScoreList takes in a TetrisScore * rather than simply a PlayerScore, ppolymorphism can be demonstrated */ public class TetrisScore extends PlayerScore { //keeps track of level as well. private static final int DEFLINES = -1; private static final int DEFLEVEL = -1; //instance variables int level; public TetrisScore(String name, int lines, int level){ //constructor with 3 parameters super(name, lines);//calls the PlayerScore constructor this.level = level; } public TetrisScore(String name){ //constructor which takes in only a name and used feault values this(name, DEFLEVEL, DEFLINES);//calls the 3 parameter constructor } public boolean checkIfScored(){ //returns true or false depending on if the player has scored return (super.getScore() != DEFLINES); } public int getLines(){ //returns the lines, aka the score return super.getScore(); } public String toString(){ //returns a String with all 3 values of the TetrisScore object String str = super.toString();//calls PlayerScore toString str += " Level: " + level; return str; } }