Hand fertig implementiert.

master
s.eser 2024-03-22 18:05:29 +01:00
parent 7fd2dad349
commit 938a994fa5
1 changed files with 25 additions and 1 deletions

View File

@ -4,10 +4,34 @@ import java.util.ArrayList;
public class Hand {
ArrayList<Karte> hand = new ArrayList<>();
private ArrayList<Karte> hand = new ArrayList<>();
Hand(Kartenstapel ks){
hand.add(ks.getKarte());
hand.add(ks.getKarte());
}
public String toString(){
String hand = "";
for (int i = 0; i<this.hand.size(); i++){
hand += this.hand.get(i).toString();
}
return hand;
}
public int getPunkte(){
int ergebnis = 0;
for(int i = 0; i<hand.size(); i++){
ergebnis += hand.get(i).getPunkte();
}
return ergebnis;
}
public boolean isBlackJack(){
if(hand.size()==2&&getPunkte()==21)
return true;
else
return false;
}