diff --git a/BlackJack/.gitignore b/BlackJack/.gitignore new file mode 100644 index 0000000..3430efb --- /dev/null +++ b/BlackJack/.gitignore @@ -0,0 +1,3 @@ +/.DS_Store +/.classpath +/.project diff --git a/BlackJack/src/.gitignore b/BlackJack/src/.gitignore new file mode 100644 index 0000000..9bb88d3 --- /dev/null +++ b/BlackJack/src/.gitignore @@ -0,0 +1 @@ +/.DS_Store diff --git a/BlackJack/src/de/.gitignore b/BlackJack/src/de/.gitignore new file mode 100644 index 0000000..9bb88d3 --- /dev/null +++ b/BlackJack/src/de/.gitignore @@ -0,0 +1 @@ +/.DS_Store diff --git a/BlackJack/src/de/hs_mannheim/.gitignore b/BlackJack/src/de/hs_mannheim/.gitignore new file mode 100644 index 0000000..9bb88d3 --- /dev/null +++ b/BlackJack/src/de/hs_mannheim/.gitignore @@ -0,0 +1 @@ +/.DS_Store diff --git a/BlackJack/src/de/hs_mannheim/informatik/.gitignore b/BlackJack/src/de/hs_mannheim/informatik/.gitignore new file mode 100644 index 0000000..9bb88d3 --- /dev/null +++ b/BlackJack/src/de/hs_mannheim/informatik/.gitignore @@ -0,0 +1 @@ +/.DS_Store diff --git a/BlackJack/src/de/hs_mannheim/informatik/casino/.gitignore b/BlackJack/src/de/hs_mannheim/informatik/casino/.gitignore new file mode 100644 index 0000000..9bb88d3 --- /dev/null +++ b/BlackJack/src/de/hs_mannheim/informatik/casino/.gitignore @@ -0,0 +1 @@ +/.DS_Store diff --git a/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/domain/Hand.java b/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/domain/Hand.java new file mode 100644 index 0000000..8b38ae4 --- /dev/null +++ b/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/domain/Hand.java @@ -0,0 +1,26 @@ +package de.hs_mannheim.informatik.casino.blackjack.domain; + +import java.util.ArrayList; + +public class Hand { + private Kartenstapel ks; + private ArrayList 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(); + } +} diff --git a/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/domain/Karte.java b/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/domain/Karte.java new file mode 100644 index 0000000..c52096e --- /dev/null +++ b/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/domain/Karte.java @@ -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 + "]"; + } + +} diff --git a/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/domain/Kartenstapel.java b/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/domain/Kartenstapel.java new file mode 100644 index 0000000..8a00ec3 --- /dev/null +++ b/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/domain/Kartenstapel.java @@ -0,0 +1,25 @@ +package de.hs_mannheim.informatik.casino.blackjack.domain; + +import java.util.ArrayList; + +public class Kartenstapel { + private ArrayList 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); + } +} diff --git a/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/facade/BlackJackSpiel.java b/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/facade/BlackJackSpiel.java new file mode 100644 index 0000000..a27aad9 --- /dev/null +++ b/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/facade/BlackJackSpiel.java @@ -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(); + } +} diff --git a/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/tui/BlackJackTUI.java b/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/tui/BlackJackTUI.java new file mode 100644 index 0000000..081188d --- /dev/null +++ b/BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/tui/BlackJackTUI.java @@ -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."); + } + +}