|
| 1 | +package models; |
| 2 | + |
| 3 | +public class Player { |
| 4 | + private String name; |
| 5 | + private int age; |
| 6 | + private int score; |
| 7 | + private int positionX; |
| 8 | + private int positionY; |
| 9 | + |
| 10 | + public Player() { |
| 11 | + this.name = ""; |
| 12 | + this.age = 0; |
| 13 | + this.score = 0; |
| 14 | + this.positionX = 0; |
| 15 | + this.positionY = 0; |
| 16 | + } |
| 17 | + |
| 18 | + public Player(String name, int age, int score, int positionX, int positionY) { |
| 19 | + this.name = name; |
| 20 | + this.age = age; |
| 21 | + this.score = score; |
| 22 | + this.positionX = positionX; |
| 23 | + this.positionY = positionY; |
| 24 | + } |
| 25 | + |
| 26 | + public void increaseScore() { |
| 27 | + this.score++; |
| 28 | + } |
| 29 | + |
| 30 | + public void decreaseScore() { |
| 31 | + this.score--; |
| 32 | + } |
| 33 | + |
| 34 | + public void increaseScore(int n) { |
| 35 | + this.score += n; |
| 36 | + } |
| 37 | + |
| 38 | + public void decreaseScore(int n) { |
| 39 | + this.score -= n; |
| 40 | + } |
| 41 | + |
| 42 | + public boolean isWinner() { |
| 43 | + if (this.score >= 100) |
| 44 | + return true; |
| 45 | + else |
| 46 | + return false; |
| 47 | + } |
| 48 | + |
| 49 | + |
| 50 | + @Override |
| 51 | + public String toString() { |
| 52 | + return "Player [name=" + name + ", age=" + age + ", score=" + score + ", positionX=" + positionX |
| 53 | + + ", positionY=" + positionY + "]"; |
| 54 | + } |
| 55 | + |
| 56 | + public String getName() { |
| 57 | + return name; |
| 58 | + } |
| 59 | + |
| 60 | + public void setName(String name) { |
| 61 | + this.name = name; |
| 62 | + } |
| 63 | + |
| 64 | + public int getAge() { |
| 65 | + return age; |
| 66 | + } |
| 67 | + |
| 68 | + public void setAge(int age) { |
| 69 | + this.age = age; |
| 70 | + } |
| 71 | + |
| 72 | + public int getScore() { |
| 73 | + return score; |
| 74 | + } |
| 75 | + |
| 76 | + public void setScore(int score) { |
| 77 | + this.score = score; |
| 78 | + } |
| 79 | + |
| 80 | + public int getPositionX() { |
| 81 | + return positionX; |
| 82 | + } |
| 83 | + |
| 84 | + public void setPositionX(int positionX) { |
| 85 | + this.positionX = positionX; |
| 86 | + } |
| 87 | + |
| 88 | + public int getPositionY() { |
| 89 | + return positionY; |
| 90 | + } |
| 91 | + |
| 92 | + public void setPositionY(int positionY) { |
| 93 | + this.positionY = positionY; |
| 94 | + } |
| 95 | +} |
0 commit comments