2023-10-12 08:51:24 +02:00
|
|
|
/*
|
|
|
|
============================================================
|
|
|
|
This is the "Stich" file from Author: Philipp Kotte
|
|
|
|
written on: 11 / 10 / 2023 at: 20:25
|
|
|
|
============================================================
|
|
|
|
*/
|
|
|
|
package Domain;
|
|
|
|
|
|
|
|
import Domain.Karten.Karte;
|
|
|
|
|
|
|
|
public class Stich {
|
|
|
|
/*------------------------------------------*/
|
|
|
|
// statische Konstanten
|
|
|
|
/*------------------------------------------*/
|
|
|
|
|
|
|
|
/*------------------------------------------*/
|
|
|
|
// statische Attribute(zB. zähler)
|
|
|
|
/*------------------------------------------*/
|
|
|
|
|
|
|
|
/*------------------------------------------*/
|
|
|
|
// Attribute jedes Objektes
|
|
|
|
/*------------------------------------------*/
|
|
|
|
private Karte[] karten;
|
2023-10-25 11:57:48 +02:00
|
|
|
private int[] spielerID;
|
|
|
|
private int kartenCount = 0;
|
2023-10-12 08:51:24 +02:00
|
|
|
/*------------------------------------------*/
|
|
|
|
// Konstruktoren (default und spezifische)
|
|
|
|
/*------------------------------------------*/
|
|
|
|
|
|
|
|
public Stich() {
|
|
|
|
}
|
|
|
|
|
2023-10-25 11:57:48 +02:00
|
|
|
public Stich(int spielerAnzahl) {
|
|
|
|
setSpielerAnzahl(spielerAnzahl);
|
2023-10-12 08:51:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------*/
|
|
|
|
// statische Methoden
|
|
|
|
/*------------------------------------------*/
|
|
|
|
|
|
|
|
/*------------------------------------------*/
|
|
|
|
// Getter und Setter
|
|
|
|
/*------------------------------------------*/
|
|
|
|
|
2023-10-25 11:57:48 +02:00
|
|
|
public void setSpielerAnzahl(int spielerAnzahl) {
|
|
|
|
this.karten = new Karte[spielerAnzahl];
|
|
|
|
this.spielerID = new int[spielerAnzahl];
|
2023-10-12 08:51:24 +02:00
|
|
|
}
|
|
|
|
|
2023-11-07 11:15:14 +01:00
|
|
|
public int getSpielerAnzahl(){
|
|
|
|
return spielerID.length;
|
|
|
|
}
|
|
|
|
|
2023-10-12 08:51:24 +02:00
|
|
|
public Karte[] getKarten() {
|
|
|
|
return this.karten;
|
|
|
|
}
|
|
|
|
|
2023-10-25 11:57:48 +02:00
|
|
|
public void addKarte(int spielerID, Karte karte) {
|
2023-11-07 11:15:14 +01:00
|
|
|
if (kartenCount > getSpielerAnzahl()){
|
|
|
|
throw new IndexOutOfBoundsException("Karten-Index überschreitet die Anzahl der Spieler");
|
|
|
|
}else {
|
|
|
|
this.karten[kartenCount] = karte;
|
|
|
|
this.spielerID[kartenCount] = spielerID;
|
|
|
|
kartenCount++;
|
|
|
|
}
|
2023-10-25 11:57:48 +02:00
|
|
|
}
|
|
|
|
|
2023-10-12 08:51:24 +02:00
|
|
|
/*------------------------------------------*/
|
|
|
|
// @Overrides
|
|
|
|
/*------------------------------------------*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
String text = "";
|
|
|
|
for (int i = 0; i < this.karten.length; i++) {
|
|
|
|
text += this.karten[i].toString();
|
|
|
|
}
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------*/
|
|
|
|
// öffentliche Methodes
|
|
|
|
/*------------------------------------------*/
|
|
|
|
|
|
|
|
/*------------------------------------------*/
|
|
|
|
// Hilfsmethoden (privat)
|
|
|
|
/*------------------------------------------*/
|
|
|
|
|
|
|
|
}
|