From 03f912bc13de4c5f73ac83920f672d7cf9378749 Mon Sep 17 00:00:00 2001 From: Oliver Hummel Date: Tue, 26 Mar 2024 12:00:33 +0100 Subject: [PATCH] Initialer Commit. --- BlackJack/.gitignore | 3 ++ BlackJack/src/.gitignore | 1 + BlackJack/src/de/.gitignore | 1 + BlackJack/src/de/hs_mannheim/.gitignore | 1 + .../src/de/hs_mannheim/informatik/.gitignore | 1 + .../hs_mannheim/informatik/casino/.gitignore | 1 + .../casino/blackjack/domain/Hand.java | 26 +++++++++++++ .../casino/blackjack/domain/Karte.java | 17 +++++++++ .../casino/blackjack/domain/Kartenstapel.java | 25 ++++++++++++ .../blackjack/facade/BlackJackSpiel.java | 22 +++++++++++ .../casino/blackjack/tui/BlackJackTUI.java | 38 +++++++++++++++++++ 11 files changed, 136 insertions(+) create mode 100644 BlackJack/.gitignore create mode 100644 BlackJack/src/.gitignore create mode 100644 BlackJack/src/de/.gitignore create mode 100644 BlackJack/src/de/hs_mannheim/.gitignore create mode 100644 BlackJack/src/de/hs_mannheim/informatik/.gitignore create mode 100644 BlackJack/src/de/hs_mannheim/informatik/casino/.gitignore create mode 100644 BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/domain/Hand.java create mode 100644 BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/domain/Karte.java create mode 100644 BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/domain/Kartenstapel.java create mode 100644 BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/facade/BlackJackSpiel.java create mode 100644 BlackJack/src/de/hs_mannheim/informatik/casino/blackjack/tui/BlackJackTUI.java 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."); + } + +}