main
Jens Reuter 2024-03-26 11:47:20 +01:00
parent fee631ee49
commit e4ee0cc7de
5 changed files with 79 additions and 0 deletions

5
src/App.java 100644
View File

@ -0,0 +1,5 @@
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Hello, World!");
}
}

View File

@ -0,0 +1,3 @@
public class BlackJackSpiel {
}

3
src/Hand.java 100644
View File

@ -0,0 +1,3 @@
public class Hand {
}

30
src/Karte.java 100644
View File

@ -0,0 +1,30 @@
public class Karte {
private String karte;
private String farbe;
private int wert;
public Karte (String karte, String farbe, int wert){
this.farbe = karte;
this.karte = farbe;
this.wert = wert;
}
public static int getPunkte(String wert){
if(wert.equalsIgnoreCase("Bube") || wert.equalsIgnoreCase("Dame") || wert.equalsIgnoreCase("König")){
return 10;
}
else if (wert.equalsIgnoreCase("Ass")){
return 11;
}
else {
return Integer.parseInt(wert);
}
}
public String toString(){
StringBuilder info = new StringBuilder();
info.append("karte").append(" ").append("farbe").append(" ");
info.append(wert);
return info.toString();
}
}

View File

@ -0,0 +1,38 @@
import java.util.ArrayList;
import java.util.Random;
public class Kartenstapel {
private ArrayList<Karte> Stapel;
private String[] karte = {"Herz", "Karo", "Kreuz", "Pik"};
private String[] farbe = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Bube", "Dame", "König"};
public Kartenstapel(){
}
public ArrayList<Karte> deckErstellen(String karte[], String[] farbe){
for(String i : karte){
for(String n : farbe){
Stapel.add(new Karte(i, n, Karte.getPunkte(i)));//getWert
}
}
return Stapel;
}
/* public String getWert(){
String temp = "";
for(int i = 0; i < farbe.length; i++){
temp = farbe[i];
}
return temp;
} */
public Karte getKarte(){
Random random = new Random();
int index = random.nextInt(52);
Karte gezogeneKarte = Stapel.get(index);
System.out.println("Du hast ein " + gezogeneKarte.toString() + "gezogen.");
return gezogeneKarte;
}
}