Kartenstapel fixes und alle Methoden implementiert.
parent
d217fc84e8
commit
7fd2dad349
|
@ -1,53 +1,53 @@
|
|||
package de.hs_mannheim.informatik.blackjack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Kartenstapel {
|
||||
Karte[] kartenstapel = new Karte[52];
|
||||
ArrayList<Karte> kartenstapel = new ArrayList<>();
|
||||
|
||||
Kartenstapel(){
|
||||
int t= 2;
|
||||
|
||||
for(int i = 0; i< 9; i++){
|
||||
kartenstapel[i] = new Karte("Kreuz", "" + t);
|
||||
t++;
|
||||
for(int i = 2; i< 11; i++){
|
||||
kartenstapel.add(new Karte("Kreuz", ""+i));
|
||||
}
|
||||
t=2;
|
||||
|
||||
for (int i = 9; i < 18; i++) {
|
||||
kartenstapel[i] = new Karte("Pik", "" + t);
|
||||
t++;
|
||||
for(int i = 2; i< 11; i++){
|
||||
kartenstapel.add(new Karte("Herz", ""+i));
|
||||
}
|
||||
t=2;
|
||||
|
||||
for (int i = 18; i < 27; i++) {
|
||||
kartenstapel[i] = new Karte("Herz", "" + t);
|
||||
t++;
|
||||
for(int i = 2; i< 11; i++){
|
||||
kartenstapel.add(new Karte("Pik", ""+i));
|
||||
}
|
||||
t=2;
|
||||
|
||||
for (int i = 27; i < 36; i++) {
|
||||
kartenstapel[i] = new Karte("Karo", "" + t);
|
||||
t++;
|
||||
for(int i = 2; i< 11; i++){
|
||||
kartenstapel.add(new Karte("Karo", ""+i));
|
||||
}
|
||||
|
||||
kartenstapel[36] = new Karte("Kreuz", "Bube");
|
||||
kartenstapel[37] = new Karte("Kreuz", "Dame");
|
||||
kartenstapel[38] = new Karte("Kreuz", "König");
|
||||
kartenstapel[39] = new Karte("Kreuz", "Ass");
|
||||
kartenstapel.add(new Karte("Kreuz", "Bube"));
|
||||
kartenstapel.add(new Karte("Kreuz", "Dame"));
|
||||
kartenstapel.add(new Karte("Kreuz", "König"));
|
||||
kartenstapel.add(new Karte("Kreuz", "Ass"));
|
||||
|
||||
kartenstapel[40] = new Karte("Pik", "Bube");
|
||||
kartenstapel[41] = new Karte("Pik", "Dame");
|
||||
kartenstapel[42] = new Karte("Pik", "König");
|
||||
kartenstapel[43] = new Karte("Pik", "Ass");
|
||||
kartenstapel.add(new Karte("Herz", "Bube"));
|
||||
kartenstapel.add(new Karte("Herz", "Dame"));
|
||||
kartenstapel.add(new Karte("Herz", "König"));
|
||||
kartenstapel.add(new Karte("Herz", "Ass"));
|
||||
|
||||
kartenstapel[44] = new Karte("Herz", "Bube");
|
||||
kartenstapel[45] = new Karte("Herz", "Dame");
|
||||
kartenstapel[46] = new Karte("Herz", "König");
|
||||
kartenstapel[47] = new Karte("Herz", "Ass");
|
||||
kartenstapel.add(new Karte("Pik", "Bube"));
|
||||
kartenstapel.add(new Karte("Pik", "Dame"));
|
||||
kartenstapel.add(new Karte("Pik", "König"));
|
||||
kartenstapel.add(new Karte("Pik", "Ass"));
|
||||
|
||||
kartenstapel[48] = new Karte("Karo", "Bube");
|
||||
kartenstapel[49] = new Karte("Karo", "Dame");
|
||||
kartenstapel[50] = new Karte("Karo", "König");
|
||||
kartenstapel[51] = new Karte("Karo", "Ass");
|
||||
kartenstapel.add(new Karte("Karo", "Bube"));
|
||||
kartenstapel.add(new Karte("Karo", "Dame"));
|
||||
kartenstapel.add(new Karte("Karo", "König"));
|
||||
kartenstapel.add(new Karte("Karo", "Ass"));
|
||||
}
|
||||
|
||||
public Karte getKarte(){
|
||||
Karte randomKarte = kartenstapel.get((int)(Math.random()*kartenstapel.size()));
|
||||
kartenstapel.remove(randomKarte);
|
||||
return randomKarte;
|
||||
}
|
||||
|
||||
public int getZahlÜbrigerKarten(){
|
||||
return kartenstapel.size();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue