Initialer Commit.

main
Oliver Hummel 2024-03-26 12:00:33 +01:00
parent 9b5492255a
commit 03f912bc13
11 changed files with 136 additions and 0 deletions

3
BlackJack/.gitignore vendored 100644
View File

@ -0,0 +1,3 @@
/.DS_Store
/.classpath
/.project

1
BlackJack/src/.gitignore vendored 100644
View File

@ -0,0 +1 @@
/.DS_Store

1
BlackJack/src/de/.gitignore vendored 100644
View File

@ -0,0 +1 @@
/.DS_Store

View File

@ -0,0 +1 @@
/.DS_Store

View File

@ -0,0 +1 @@
/.DS_Store

View File

@ -0,0 +1 @@
/.DS_Store

View File

@ -0,0 +1,26 @@
package de.hs_mannheim.informatik.casino.blackjack.domain;
import java.util.ArrayList;
public class Hand {
private Kartenstapel ks;
private ArrayList<Karte> karten;
public Hand(Kartenstapel ks) {
this.ks = ks;
karten = new ArrayList<>(11);
karten.add(ks.getKarte());
karten.add(ks.getKarte());
}
public void neueKarte() {
karten.add(ks.getKarte());
}
public String toString() {
return karten.get(0).toString() + " "
+ karten.get(1).toString();
}
}

View File

@ -0,0 +1,17 @@
package de.hs_mannheim.informatik.casino.blackjack.domain;
public class Karte {
private String farbe;
private String name;
public Karte(String farbe, String name) {
this.farbe = farbe;
this.name = name;
}
@Override
public String toString() {
return "Karte [farbe=" + farbe + ", name=" + name + "]";
}
}

View File

@ -0,0 +1,25 @@
package de.hs_mannheim.informatik.casino.blackjack.domain;
import java.util.ArrayList;
public class Kartenstapel {
private ArrayList<Karte> karten;
public Kartenstapel() {
karten = new ArrayList<>(52);
karten.add(new Karte("Pik", "Ass"));
karten.add(new Karte("Herz", "Bube"));
karten.add(new Karte("Herz", "Dame"));
// mischen();
}
// private void mischen() { }
public Karte getKarte() {
int karte = (int) (Math.random() * karten.size());
return karten.remove(karte);
}
}

View File

@ -0,0 +1,22 @@
package de.hs_mannheim.informatik.casino.blackjack.facade;
import de.hs_mannheim.informatik.casino.blackjack.domain.Hand;
import de.hs_mannheim.informatik.casino.blackjack.domain.Kartenstapel;
public class BlackJackSpiel {
private Kartenstapel ks;
private Hand hand;
public BlackJackSpiel() {
ks = new Kartenstapel();
hand = new Hand(ks);
}
public String getHandInhalt() {
return hand.toString();
}
public void neueKarte() {
hand.neueKarte();
}
}

View File

@ -0,0 +1,38 @@
package de.hs_mannheim.informatik.casino.blackjack.tui;
import de.hs_mannheim.informatik.casino.blackjack.domain.Hand;
import de.hs_mannheim.informatik.casino.blackjack.facade.BlackJackSpiel;
public class BlackJackTUI {
private BlackJackSpiel bjs;
public static void main(String[] args) {
new BlackJackTUI();
}
public BlackJackTUI() {
System.out.println("Willkommen zu Blackjack!");
bjs = new BlackJackSpiel();
spielBildschirm();
}
public void spielBildschirm() {
System.out.println();
System.out.println("Das Spiel beginnt.");
System.out.println();
// Hand hand = bjs.getHand();
// hand.neueKarte();
System.out.println(bjs.getHandInhalt());
System.out.println("3. Karte");
bjs.neueKarte();
System.out.println(bjs.getHandInhalt());
System.out.println("Auf Wiedersehen.");
}
}