Spieler class

main
danai 2024-05-06 23:28:31 +02:00
parent a8e4e484ad
commit 8fae72aba7
1 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,71 @@
package domain;
public class Spieler {
private int number;
private String Name;
private int[] scores;
private int score;
public Spieler(int number) {
this.number = number;
this.Name = "";
this.scores = new int[Kategorie.values().length];
this.score = 0;
}
public Spieler() {
this(0);
}
public int getNumber() {
return number + 1;
}
public void setNumber(int number) {
this.number = number;
}
public String getName() {
return Name;
}
public void setName(String Name) {
this.Name = Name;
}
public int getScore(int categoryIndex) {
return scores[categoryIndex];
}
public void setScore(int categoryIndex, int score) {
scores[categoryIndex] = score;
}
public void setScoreForCategory(int categoryIndex, int score) {
this.score = score;
// Дополнительная логика, если необходимо
}
public int getTotalScore() {
int totalScore = 0;
for (int score : scores) {
totalScore += score;
}
return totalScore;
}
public void resetScore() {
for (int i = 0; i < scores.length; i++) {
scores[i] = 0;
}
}
}