Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
62efd92
Setting up GitHub Classroom Feedback
xt0fer Nov 16, 2020
d04f2a0
uml-structure
MrKutchen Nov 17, 2020
723a658
further development of the UML
MrKutchen Nov 17, 2020
6e7c94f
working through menus
MrKutchen Nov 17, 2020
6e5ca4f
succesful unit test
MrKutchen Nov 18, 2020
78123f8
blackjack
kppetrick Nov 18, 2020
dd90e47
Merge pull request #2 from ZCW-Java6dot2/dev
kppetrick Nov 18, 2020
930e0f1
added features to deck class and blackjack class
jamiepompei Nov 18, 2020
29f15e8
Merge pull request #3 from ZCW-Java6dot2/dev
AmandaMWilliams Nov 18, 2020
7aa68b8
Merge pull request #4 from ZCW-Java6dot2/dev
kppetrick Nov 18, 2020
d345c54
menu improvements
MrKutchen Nov 18, 2020
377fd46
Snake eye init
Nov 18, 2020
314da22
Merge branch 'dev' into feature-menus
MrKutchen Nov 18, 2020
7915d4b
Merge pull request #5 from ZCW-Java6dot2/feature-menus
MrKutchen Nov 18, 2020
4b7915c
Merge branch 'dev' of https://github.com/ZCW-Java6dot2/cats-casino in…
AmandaMWilliams Nov 18, 2020
ca472c6
added handValue method to DeckOfCards
AmandaMWilliams Nov 18, 2020
85d3ed7
Renamed BlackJackTable to BlackjackEngine, renamed Gambling to Gambler
AmandaMWilliams Nov 18, 2020
b02f1cb
BlackjackPlayer implements Gambler, made BlackjackEngine constructor
AmandaMWilliams Nov 18, 2020
4573a5c
Changed GoFishTable to GoFishEngine, created GoFishEngine constructor
AmandaMWilliams Nov 18, 2020
b11829e
Merge pull request #6 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 18, 2020
316237c
Changed vault to Integers, Created Notes class to be deleted later
AmandaMWilliams Nov 18, 2020
385584b
Partial Blackjack gameplay
AmandaMWilliams Nov 18, 2020
af84755
Menu alterations
MrKutchen Nov 18, 2020
12a5104
More Blackjack gameplay
AmandaMWilliams Nov 18, 2020
a157b06
Blackjack gameplay complete but messy
AmandaMWilliams Nov 18, 2020
f5dc276
try/catch for Blackjack
AmandaMWilliams Nov 18, 2020
7482404
Create BlackjackNotes.java
AmandaMWilliams Nov 18, 2020
fcfee87
SnakeEyes Updates
Nov 18, 2020
2ab2c09
SnakeEyes features updated
Nov 18, 2020
8e95464
Rename BlackjackNotes.java to BlackjackNotes
AmandaMWilliams Nov 18, 2020
6cf2c76
added specific dealer classes
jamiepompei Nov 18, 2020
b40c702
took out gamenotes
MrKutchen Nov 18, 2020
8ca3825
trying to resolve merge conflict
AmandaMWilliams Nov 18, 2020
ff7c7d6
Merge pull request #9 from ZCW-Java6dot2/feature-peter
MrKutchen Nov 18, 2020
bb00d9a
fix game notes class
AmandaMWilliams Nov 18, 2020
ce746b0
merge conflict
AmandaMWilliams Nov 19, 2020
275f3ab
commit
AmandaMWilliams Nov 19, 2020
55abbf5
BlackjackGameNotes and Account class fix
AmandaMWilliams Nov 19, 2020
44a888a
Merge pull request #11 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 19, 2020
5a327aa
merge conflict
Nov 19, 2020
e605f9e
Merge branch 'dev' into featShubham
shubham-amatya Nov 19, 2020
49de83b
Merge pull request #12 from ZCW-Java6dot2/featShubham
shubham-amatya Nov 19, 2020
7bac783
merge conflicts
jamiepompei Nov 19, 2020
b0126c7
Merge pull request #13 from ZCW-Java6dot2/pompyFeature
jamiepompei Nov 19, 2020
43cbbcc
Merge branch 'dev' of https://github.com/ZCW-Java6dot2/cats-casino in…
jamiepompei Nov 19, 2020
8d2a962
update Card class, delete enum classes for card suites and values
AmandaMWilliams Nov 19, 2020
4d4c3ed
Merge pull request #14 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 19, 2020
58d66c9
Updated Hand Class
AmandaMWilliams Nov 19, 2020
e4280dc
Merge pull request #15 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 19, 2020
8522f1b
Complete Snake Eye game
Nov 19, 2020
b5326fe
Merge pull request #16 from ZCW-Java6dot2/featShubham
shubham-amatya Nov 19, 2020
7a67aab
Added BlackjackDealer class
AmandaMWilliams Nov 19, 2020
9ac33f5
Merge pull request #17 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 19, 2020
2245b69
BJ Dealer complete
AmandaMWilliams Nov 19, 2020
aa5ede9
Blackjack dealer and blackjack player classes complete
AmandaMWilliams Nov 19, 2020
edcbcda
Merge pull request #18 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 19, 2020
77bbca8
deleted some merge stuff
jamiepompei Nov 19, 2020
0b6c48f
added all the things to blackjack class
jamiepompei Nov 19, 2020
1dc6a91
Merge pull request #20 from ZCW-Java6dot2/pompyFeature
jamiepompei Nov 19, 2020
30ec1be
Refactored menus / structure of account vs player
MrKutchen Nov 19, 2020
8e5cfd4
Merge pull request #21 from ZCW-Java6dot2/feature-peter
MrKutchen Nov 19, 2020
f9d064d
deleted blackjack
MrKutchen Nov 19, 2020
baaceb8
Merge pull request #22 from ZCW-Java6dot2/feature-peter
MrKutchen Nov 19, 2020
e5a956c
PlayerWarehouse
MrKutchen Nov 19, 2020
171736c
Merge pull request #23 from ZCW-Java6dot2/feature-peter
MrKutchen Nov 19, 2020
f706398
Tidy up BlackjackGame class for test making
AmandaMWilliams Nov 19, 2020
3c597c6
Merge pull request #24 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 19, 2020
bdbad7d
Added nonfunctional PlayerTests
AmandaMWilliams Nov 19, 2020
30dac8d
Merge pull request #25 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 19, 2020
4621931
Added PlayerWarehouseTest
AmandaMWilliams Nov 19, 2020
211679f
Merge pull request #26 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 19, 2020
06f1efe
added test to PlayerWarehouseTest
AmandaMWilliams Nov 19, 2020
acb86e8
Merge pull request #27 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 19, 2020
8a1c2a3
Added AccountTests
AmandaMWilliams Nov 19, 2020
7284ee1
Merge pull request #28 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 19, 2020
40fd78b
goFish
kppetrick Nov 19, 2020
d69d6f0
Added BlackjackPlayerTests
AmandaMWilliams Nov 19, 2020
6f0fbb4
Merge pull request #29 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 19, 2020
c7b49f1
Merge branch 'dev' of https://github.com/ZCW-Java6dot2/cats-casino in…
kppetrick Nov 19, 2020
a76c26f
working on craps
MrKutchen Nov 19, 2020
fec4599
menus fixed
MrKutchen Nov 19, 2020
f91cfec
most recent changes to unit tests
MrKutchen Nov 20, 2020
ad0760f
Merge pull request #30 from ZCW-Java6dot2/feature-peter
MrKutchen Nov 20, 2020
008c0d4
BlackJackGameTest class complete
AmandaMWilliams Nov 20, 2020
2faf645
gofish
kppetrick Nov 20, 2020
470a766
Update CardTest and BlackjackGameEngineTest
AmandaMWilliams Nov 20, 2020
c8f43f9
Merge branch 'dev' into feat/amanda
AmandaMWilliams Nov 20, 2020
51cbc31
Merge pull request #31 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 20, 2020
0fcc103
craps done...hopefully
MrKutchen Nov 20, 2020
4dd2464
Merge branch 'dev' into feature-peter
AmandaMWilliams Nov 20, 2020
e4e7b80
Merge pull request #32 from ZCW-Java6dot2/feature-peter
AmandaMWilliams Nov 20, 2020
e7317f9
Merge branch 'dev' of https://github.com/ZCW-Java6dot2/cats-casino in…
kppetrick Nov 20, 2020
95fe60d
sorta close to menu done
kppetrick Nov 20, 2020
a26e6ec
Merge pull request #33 from ZCW-Java6dot2/feature-kyle
AmandaMWilliams Nov 20, 2020
de09954
deleted craps engine
MrKutchen Nov 20, 2020
500a265
Merge branch 'feature-peter' of https://github.com/ZCW-Java6dot2/cats…
MrKutchen Nov 20, 2020
487981d
erge branch 'dev' of https://github.com/ZCW-Java6dot2/cats-casino int…
MrKutchen Nov 20, 2020
059aa17
Merge pull request #34 from ZCW-Java6dot2/feature-peter
MrKutchen Nov 20, 2020
5ec45fa
Delete table tests
AmandaMWilliams Nov 20, 2020
b813ae5
Merge pull request #35 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 20, 2020
66c1977
.........
MrKutchen Nov 20, 2020
72b1fc3
Merge pull request #36 from ZCW-Java6dot2/feature-peter
MrKutchen Nov 20, 2020
c8cdac3
CasinoTest added
AmandaMWilliams Nov 20, 2020
dc5464b
added CardTest
AmandaMWilliams Nov 20, 2020
d8ed37b
Merge pull request #37 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 20, 2020
590c4fd
added GoFishTest
AmandaMWilliams Nov 20, 2020
6b17b37
Merge pull request #38 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 20, 2020
3499378
added DieTest
AmandaMWilliams Nov 20, 2020
f36a5fa
Merge pull request #39 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 20, 2020
ff92872
added BJGameTest
AmandaMWilliams Nov 20, 2020
cba2334
Merge pull request #40 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 20, 2020
0b0143b
commenting out clocking tests
AmandaMWilliams Nov 20, 2020
fa7e40c
Merge pull request #41 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 20, 2020
6067e25
added HandTest
AmandaMWilliams Nov 20, 2020
7525238
fixed AccountTest
AmandaMWilliams Nov 20, 2020
62258db
Merge pull request #42 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 20, 2020
dd0bab1
gofish show hand works 1 line
kppetrick Nov 20, 2020
c6a8f2e
card display cleaner no of
kppetrick Nov 20, 2020
3042022
fixed PlayerTest
AmandaMWilliams Nov 20, 2020
6021412
Merge pull request #43 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 20, 2020
446e982
Merge pull request #44 from ZCW-Java6dot2/feature-kyle
kppetrick Nov 20, 2020
df33f85
craps works
MrKutchen Nov 20, 2020
1bbdde2
Merge pull request #45 from ZCW-Java6dot2/feature-peter
MrKutchen Nov 20, 2020
10636ec
Update BJDTest
AmandaMWilliams Nov 20, 2020
edcdfe7
Merge pull request #46 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 20, 2020
d273019
Deleted unused classes
AmandaMWilliams Nov 20, 2020
dc5cda1
Merge pull request #47 from ZCW-Java6dot2/feat/amanda
AmandaMWilliams Nov 20, 2020
ca93ed2
altered blackjack and attempted to improve
MrKutchen Nov 20, 2020
5c4d549
Merge pull request #48 from ZCW-Java6dot2/feature-peter
AmandaMWilliams Nov 20, 2020
d885690
final commit
MrKutchen Nov 20, 2020
2523db1
Merge pull request #49 from ZCW-Java6dot2/feature-peter
AmandaMWilliams Nov 20, 2020
2bef1e6
Actual final commit
MrKutchen Nov 20, 2020
f398326
Merge pull request #50 from ZCW-Java6dot2/feature-peter
AmandaMWilliams Nov 20, 2020
b527f0f
Merge pull request #51 from ZCW-Java6dot2/dev
MrKutchen Nov 20, 2020
90daf07
Update README.md
shubham-amatya Jan 19, 2021
a62198a
Update README.md
shubham-amatya Feb 5, 2021
23bbb07
Merge pull request #52 from ZCW-Java6dot2/shubham-amatya-patch-1
shubham-amatya Feb 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added 21
Empty file.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Go Fish a card game
* BlackJack a card game
* Craps a dice game
* An additional dice game
* Snake eye

## Specs
* The project should include some concept of
Expand All @@ -28,4 +28,4 @@
* `BlackJack` and `GoFish` are both card games and should therefore inherit from a common `CardGame`.
* Any common logic or fields between the games should live CardGame class, **not** BlackJack **nor** GoFish.
* You must have a completed and approved UML diagram before you proceed to do any development
* All public methods should be tested.
* All public methods should be tested
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
212 changes: 212 additions & 0 deletions src/main/java/games/cardgames/BlackjackGame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
package games.cardgames;

import interfaces.GamblingGame;
import interfaces.Game;
import io.zipcoder.casino.utilities.Console;
import menus.CardGameMenu;
import player.Account;
import player.BlackjackPlayer;
import player.FatCatDealer.BlackjackDealer;

import java.util.ArrayList;

public class BlackjackGame implements Game, GamblingGame {
private Console console;
private DeckOfCards deck = new DeckOfCards();
private BlackjackPlayer player;
private BlackjackDealer fatCat;
private Integer playersBet;
private boolean stillPlaying;
private Integer input;
Integer makeDecision;
private CardGameMenu cardGameMenu;
private Account currentAccount;


public BlackjackGame(BlackjackPlayer player, BlackjackDealer fatCat, Console console) {
this.player = player;
this.currentAccount = player.getPlayersAccount();
this.fatCat = fatCat;
this.playersBet = 0;
this.stillPlaying = true;
this.console = console;
}

public DeckOfCards getDeck() {
return deck;
}

public void drawCardPlayer() {
player.hit(deck.getCard());
}

public void drawCardDealer() {
fatCat.hit(deck.getCard());
}

public int getScorePlayer() {
return player.getScore();
}

public int getScoreDealer() {
return fatCat.getScore();
}

public boolean bustPlayer() {
if (getScorePlayer() > 21) {
return true;
}
return false;
}

public boolean bustDealer() {
if (getScoreDealer() > 21) {
return true;
}
return false;
}

public Integer getPlayerBet() {
if (currentAccount.getBalance() == 0) {
//insert something here
}
playersBet = console.getIntegerInput("You have $" + currentAccount + ", how much would you like to bet?");
while (playersBet > currentAccount.getBalance() || playersBet < 1) {
playersBet = console.getIntegerInput("Please enter a valid bet.");
}
return playersBet;
}

public void placeBet() {
currentAccount.setBalance(player.getPlayersAccount().getBalance() - playersBet);
}

public void winnings(Integer playersBet) {
currentAccount.setBalance(currentAccount.getBalance() + playersBet * 2);

}

public void push(Integer playersBet) {
currentAccount.setBalance(currentAccount.getBalance() + playersBet);
}

public void setPlayerHand() {
player.getHand().add(deck.getCard());
player.getHand().add(deck.getCard());
}

public ArrayList<Card> getPlayerHand() {
return player.getHand();
}

public void setDealerHand() {
fatCat.getHand().add(deck.getCard());
fatCat.getHand().add(deck.getCard());
}

public Boolean checkBlackjack() {
if (this.fatCat.checkBlackjack() && this.player.checkBlackjack()) {
console.println("Push! You both got Blackjack.\n");
push(playersBet);
return true;
}
if (this.fatCat.checkBlackjack() && !this.player.checkBlackjack()) {
console.println("You lost! Fat Cat got Blackjack.\n");
return true;
}
if (!this.fatCat.checkBlackjack() && this.player.checkBlackjack()) {
console.println("You win! Player got Blackjack.\n");
winnings(playersBet);
return true;
}
return false;
}

public void startGame() {
//TODO
// console.println(String.format("Welcome to ", getGameName(gameName), "!"));

while (stillPlaying) {
deck.createDeck();
deck.shuffleDeck();
setPlayerHand();
setDealerHand();

input = console.getIntegerInput("Would you like to play a hand or leave? \n1: Play a hand \n2: Leave the game\n");
while (input != 1 && input != 2) {
input = console.getIntegerInput("Would you like to play a hand or leave? \n1: Play a hand \n2: Leave the game\n");
}
if (input == 2) {
cardGameMenu.runCardGameMenu(player);
} else {
getPlayerBet();
placeBet();
}

console.println(fatCat.fatCatFaceUpCard() + "\n");
console.println(getPlayerHand().toString() + "\n");

if (checkBlackjack()) {
continue;
}


makeDecision = console.getIntegerInput("\n1: Hit \n2: Stay");
while (player.getScore() <= 21) {
while (makeDecision != 1 && makeDecision != 2) {
makeDecision = console.getIntegerInput("\n1: Hit \n2: Stay");
}
if (makeDecision == 1) {
drawCardPlayer();
console.println(getPlayerHand().toString() + "\n");
if (player.getScore() <= 21) {
makeDecision = console.getIntegerInput("\n1: Hit \n2: Stay");
}

if (bustPlayer()) {
console.println("You busted!");
player.getHand().clear();
fatCat.getHand().clear();
break;
}
}
if (makeDecision == 2) {
console.println(player.toString());
console.println(fatCat.toString());
while (fatCat.getScore() < 17) {
drawCardDealer();
console.println(fatCat.toString() + "\n");
break;
}

if (bustDealer()) {
console.println("Fat Cat Busted. You win!");
winnings(playersBet);
player.getHand().clear();
fatCat.getHand().clear();
break;
}
if (fatCat.getScore() > player.getScore()) {
console.println("Fat Cat Wins!");
player.getHand().clear();
fatCat.getHand().clear();
break;
}
if (fatCat.getScore() < player.getScore()) {
console.println("You win!");
winnings(playersBet);
player.getHand().clear();
fatCat.getHand().clear();
break;
} else {
console.println("You pushed!");
push(playersBet);
player.getHand().clear();
fatCat.getHand().clear();
break;
}
}
}
}
}
}
79 changes: 79 additions & 0 deletions src/main/java/games/cardgames/Card.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package games.cardgames;

public class Card implements Comparable<Card> {
private String cardSuits;
private Integer cardValue;

public Card(String cardSuits, Integer cardValue) {
this.cardSuits = cardSuits;
this.cardValue = cardValue;
}

public String getSuit() {
return cardSuits;
}

public Integer getValue() {
return cardValue;
}

@Override
public String toString() {
if (this.getValue() == 1) {
if (this.getSuit() == "Hearts") {
return "Ace ♥";
} else if (this.getSuit() == "Spades") {
return "Ace ♠";
} else if (this.getSuit() == "Clubs") {
return "Ace ♣";
} else {
return "Ace ♦";
}
} else if (this.getValue() > 1 && this.getValue() < 11) {
if (this.getSuit() == "Hearts") {
return this.getValue() + " ♥";
} else if (this.getSuit() == "Spades") {
return this.getValue() + " ♠";
} else if (this.getSuit() == "Clubs") {
return this.getValue() + " ♣";
} else {
return this.getValue() + " ♦";
}
} else if (this.getValue() == 11) {
if (this.getSuit() == "Hearts") {
return "Jack ♥";
} else if (this.getSuit() == "Spades") {
return "Jack ♠";
} else if (this.getSuit() == "Clubs") {
return "Jack ♣";
} else {
return "Jack ♦";
}
} else if (this.getValue() == 12) {
if (this.getSuit() == "Hearts") {
return "Queen ♥";
} else if (this.getSuit() == "Spades") {
return "Queen ♠";
} else if (this.getSuit() == "Clubs") {
return "Queen ♣";
} else {
return "Queen ♦";
}
} else if (this.getValue() == 13) {
if (this.getSuit() == "Hearts") {
return "King ♥";
} else if (this.getSuit() == "Spades") {
return "King ♠";
} else if (this.getSuit() == "Clubs") {
return "King ♣";
} else {
return "King ♦";
}
}
return "error";
}

public int compareTo(Card c) {
return this.getValue().compareTo(c.getValue());
}
}
62 changes: 62 additions & 0 deletions src/main/java/games/cardgames/DeckOfCards.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package games.cardgames;

import java.util.Collections;
import java.util.Stack;

public class DeckOfCards {
Stack<Card> deck;


public DeckOfCards() {
this.deck = new Stack<Card>();
}

public void createDeck() {
for (int i = 0; i < 4; i++) {
for (int j = 1; j <= 13; j++) {
if (i == 0) {
Card card = new Card("♥", j); //hearts
deck.push(card);
} else if (i == 1) {
Card card = new Card("♠", j); //spades
deck.push(card);
} else if (i == 2) {
Card card = new Card("♦", j); //diamonds
deck.push(card);
} else if (i == 3) {
Card card = new Card("♣", j); //clubs
deck.push(card);
}
}
}
}

public Stack<Card> getStack() {
return deck;
}

public void shuffleDeck() {
Collections.shuffle(deck);
}

public void removeCard(int i) {
this.deck.remove(i);
}

public Card getCard() {
return deck.pop();
}

public boolean isEmpty(){
return deck.isEmpty();
}

public Card peekStack(){
return deck.peek();
}

public int deckSize() {
return this.deck.size();
}

}
Loading