Jason Gibbs 6 лет назад
Родитель
Сommit
a4f5409aa4

+ 33
- 0
src/main/java/io/zipcoder/casino/Card.java Просмотреть файл

@@ -0,0 +1,33 @@
1
+package io.zipcoder.casino;
2
+
3
+public class Card {
4
+
5
+    private Suit suit;
6
+    private Rank rank;
7
+
8
+    public Card(Suit suit, Rank rank) {
9
+        this.suit = suit;
10
+        this.rank = rank;
11
+    }
12
+
13
+    public Rank getRank() {
14
+        return rank;
15
+    }
16
+
17
+    public Suit getSuit() {
18
+        return suit;
19
+    }
20
+
21
+    public void setRank(Rank rank) {
22
+        this.rank = rank;
23
+    }
24
+
25
+    public void setSuit(Suit suit) {
26
+        this.suit = suit;
27
+    }
28
+
29
+    @Override
30
+    public String toString() {
31
+        return rank + " of " + suit;
32
+    }
33
+}

+ 25
- 0
src/main/java/io/zipcoder/casino/CardDeck.java Просмотреть файл

@@ -0,0 +1,25 @@
1
+package io.zipcoder.casino;
2
+import java.util.List;
3
+import java.util.ArrayList;
4
+import java.util.Random;
5
+
6
+public class CardDeck {
7
+
8
+    private Card card;
9
+    private List<Card> deck = new ArrayList<Card>(52);
10
+    private Random rand = new Random();
11
+
12
+    public CardDeck() {
13
+
14
+        for (Suit s : Suit.values()) {
15
+            for (Rank r : Rank.values()) {
16
+                deck.add(new Card(s, r));
17
+            }
18
+        }
19
+    }
20
+
21
+    public List<Card> getDeck() {
22
+        System.out.println(deck.toString());
23
+        return deck;
24
+    }
25
+}

+ 6
- 0
src/main/java/io/zipcoder/casino/Casino.java Просмотреть файл

@@ -2,4 +2,10 @@ package io.zipcoder.casino;
2 2
 
3 3
 
4 4
 public class Casino {
5
+
6
+    public static void main(String[] args) {
7
+
8
+        CardDeck cardDeck = new CardDeck();
9
+        cardDeck.getDeck();
10
+    }
5 11
 }

+ 43
- 0
src/main/java/io/zipcoder/casino/Player.java Просмотреть файл

@@ -0,0 +1,43 @@
1
+package io.zipcoder.casino;
2
+
3
+public class Player {
4
+
5
+    private String name;
6
+    private int bankroll;
7
+    private int score;
8
+
9
+    public Player(String name) {
10
+        this.name = name;
11
+        bankroll = 1000;
12
+    }
13
+
14
+    public void setName(String name) {
15
+        this.name = name;
16
+    }
17
+
18
+    public String getName() {
19
+        return name;
20
+    }
21
+
22
+    public int getBankroll() {
23
+        return bankroll;
24
+    }
25
+
26
+    public void addToBankroll(int winnings) {
27
+        bankroll += winnings;
28
+    }
29
+
30
+    public void subtractFromBankroll(int losings) {
31
+        bankroll -= losings;
32
+    }
33
+
34
+    public void setScore(int value) {
35
+        score += value;
36
+    }
37
+
38
+    public int getScore() {
39
+        return score;
40
+    }
41
+
42
+
43
+}

+ 7
- 0
src/main/java/io/zipcoder/casino/Rank.java Просмотреть файл

@@ -0,0 +1,7 @@
1
+package io.zipcoder.casino;
2
+
3
+public enum Rank {
4
+
5
+    TWO, THREE, FOUR, FIVE, SIX, SEVEN,
6
+    EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE;
7
+}

+ 6
- 0
src/main/java/io/zipcoder/casino/Suit.java Просмотреть файл

@@ -0,0 +1,6 @@
1
+package io.zipcoder.casino;
2
+
3
+public enum Suit {
4
+
5
+    SPADES, HEARTS, DIAMONDS, CLUBS;
6
+}