diff --git a/src/App.java b/src/App.java new file mode 100644 index 0000000..66c700f --- /dev/null +++ b/src/App.java @@ -0,0 +1,5 @@ +public class App { + public static void main(String[] args) throws Exception { + System.out.println("Hello, World!"); + } +} \ No newline at end of file diff --git a/src/BlackJackSpiel.java b/src/BlackJackSpiel.java new file mode 100644 index 0000000..58f6def --- /dev/null +++ b/src/BlackJackSpiel.java @@ -0,0 +1,3 @@ +public class BlackJackSpiel { + +} diff --git a/src/Hand.java b/src/Hand.java new file mode 100644 index 0000000..7e4e7c8 --- /dev/null +++ b/src/Hand.java @@ -0,0 +1,3 @@ +public class Hand { + +} diff --git a/src/Karte.java b/src/Karte.java new file mode 100644 index 0000000..5a54ca3 --- /dev/null +++ b/src/Karte.java @@ -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(); + } +} diff --git a/src/Kartenstapel.java b/src/Kartenstapel.java new file mode 100644 index 0000000..96a3101 --- /dev/null +++ b/src/Kartenstapel.java @@ -0,0 +1,38 @@ +import java.util.ArrayList; +import java.util.Random; + +public class Kartenstapel { + private ArrayList 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 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; + } +}