From 8fae72aba70c6bc2450e6fa78d4b0206e8f74ec2 Mon Sep 17 00:00:00 2001 From: danai Date: Mon, 6 May 2024 23:28:31 +0200 Subject: [PATCH] Spieler class --- KniffelSpiel/src/domain/Spieler.java | 71 ++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 KniffelSpiel/src/domain/Spieler.java diff --git a/KniffelSpiel/src/domain/Spieler.java b/KniffelSpiel/src/domain/Spieler.java new file mode 100644 index 0000000..df2ab35 --- /dev/null +++ b/KniffelSpiel/src/domain/Spieler.java @@ -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; + } + } + + + +}