From b7bd1c0756162fb20321a2ed120a58ee4df6981e Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 12 Jul 2021 21:47:00 -0400 Subject: [PATCH 01/48] Star squad --- .../zipcodewilmington/casino/models/Card.java | 54 +++++++++++++++++ .../github/zipcodewilmington/CardsTest.java | 59 +++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 src/main/java/com/github/zipcodewilmington/casino/models/Card.java create mode 100644 src/test/java/com/github/zipcodewilmington/CardsTest.java diff --git a/src/main/java/com/github/zipcodewilmington/casino/models/Card.java b/src/main/java/com/github/zipcodewilmington/casino/models/Card.java new file mode 100644 index 000000000..3464cec6f --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/models/Card.java @@ -0,0 +1,54 @@ +package com.github.zipcodewilmington.casino.models; + +import java.util.*; + +public class Card { + List cardPool; + Integer numberOfCards; // The deck will be made of + + public Card () { + this.numberOfCards = 52; + this.cardPool = new ArrayList<>(); + this.createDeck(numberOfCards); + } + + + public List createDeck (Integer numberOfCards) { + for (int i = 0; i <= 4; i++) { + for (int j = 2; j < (numberOfCards / 4); j++) { + this.cardPool.add(j); + } + } + return this.cardPool; + } + + public List polishDeck () { + for (int i = 0; i < this.cardPool.size(); i++) { + if (this.cardPool.get(i) > 11) { + this.cardPool.set(i, 10); + } + } + return this.cardPool; + } + + public List shuffleDeck () { + Collections.shuffle(this.cardPool); + return this.cardPool; + } + + public List getCardPool() { + return cardPool; + } + + public void setCardPool(List cardPool) { + this.cardPool = cardPool; + } + + public Integer getNumberOfCards() { + return numberOfCards; + } + + public void setNumberOfCards(Integer numberOfCards) { + this.numberOfCards = numberOfCards; + } +} diff --git a/src/test/java/com/github/zipcodewilmington/CardsTest.java b/src/test/java/com/github/zipcodewilmington/CardsTest.java new file mode 100644 index 000000000..269c3b91e --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/CardsTest.java @@ -0,0 +1,59 @@ +package com.github.zipcodewilmington; + +import com.github.zipcodewilmington.casino.models.Card; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; + +public class CardsTest { + @Test + public void constructorTest () { + Integer expected = 52; + + Card card = new Card(); + Integer actual = card.getNumberOfCards(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void createDeckTest () { + // Given + Card card = new Card(); + + Integer expected = 52; + Integer actual = card.getNumberOfCards(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void polishDeckTest () { + Card card = new Card(); + + card.createDeck(52); + List result = card.polishDeck(); + + System.out.println(result); + } + + @Test + public void shuffleDeckTest () { + Card card = new Card(); + + List result = card.shuffleDeck(); + + System.out.println(result); // Visual test + } + + @Test + public void setCardPoolTest () { + Card card = new Card(); + } + + @Test + public void setNumberOfCardsTest () { + + } +} From 05d5a74b79d4f5ff63b2fbf06adde18c4ed00301 Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 12 Jul 2021 21:58:29 -0400 Subject: [PATCH 02/48] edited GameInterface --- .../casino/GameInterface.java | 19 ++++++++++++++++++- .../casino/games/slots/SlotsGame.java | 3 ++- .../casino/games/slots/SlotsPlayer.java | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java index 9873f1ed9..4f5e662c5 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java +++ b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java @@ -1,7 +1,8 @@ package com.github.zipcodewilmington.casino; /** - * Created by leon on 7/21/2020. + * Author: Nathan + * Date: 7/12/21 */ public interface GameInterface extends Runnable { /** @@ -20,4 +21,20 @@ public interface GameInterface extends Runnable { * specifies how the game will run */ void run(); + + /** + * Calculate player's winning payout amount of bet x multiplier + * @return (double) amount of money winnings + */ + Double calculateWinnings(Double betAmount); + + /** + * Subtract the bet amount from player's balance + */ + void subtractBetFromBalance(Double betAmount); + + /** + * Add winnings amount to player's balance + */ + void addMoneyToBalance(PlayerInterface Player, Double winnings); } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java index 8cb20c787..78d2fca4d 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java @@ -1,7 +1,8 @@ package com.github.zipcodewilmington.casino.games.slots; /** - * Created by leon on 7/21/2020. + * Created by Nathan on 7/12/21 */ public class SlotsGame { + } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsPlayer.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsPlayer.java index f89ebd7f5..c5c6df9d3 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsPlayer.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsPlayer.java @@ -4,4 +4,5 @@ * Created by leon on 7/21/2020. */ public class SlotsPlayer { + } \ No newline at end of file From 37cd7b09f7f3f4f89edf6197da0f4e306711d323 Mon Sep 17 00:00:00 2001 From: Zach Date: Mon, 12 Jul 2021 22:08:57 -0400 Subject: [PATCH 03/48] completed Dice class and tests --- .../zipcodewilmington/casino/models/Dice.java | 65 ++++++++++++++ .../github/zipcodewilmington/DiceTest.java | 88 +++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 src/main/java/com/github/zipcodewilmington/casino/models/Dice.java create mode 100644 src/test/java/com/github/zipcodewilmington/DiceTest.java diff --git a/src/main/java/com/github/zipcodewilmington/casino/models/Dice.java b/src/main/java/com/github/zipcodewilmington/casino/models/Dice.java new file mode 100644 index 000000000..3df284267 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/models/Dice.java @@ -0,0 +1,65 @@ +package com.github.zipcodewilmington.casino.models; + +public class Dice { + private Integer numDice; + private Integer maxRoll; + private Integer maxBinIndex; + private Integer[] rollValues; + private Integer[] bins; + + public Dice(Integer numberOfDice){ + this.numDice = numberOfDice; + this.maxRoll = numberOfDice * 6; + this.maxBinIndex = numberOfDice * 6 - numberOfDice - 1; + this.rollValues = new Integer[this.numDice]; + this.bins = new Integer[numberOfDice * 6 - numberOfDice - 1]; + this.initializeDiceList(); + this.initializeBins(); + } + + public Integer getNumDice(){ + return this.numDice; + } + + public Integer[] getRollValues(){ + return this.rollValues; + } + + public Integer[] getBins(){ + return this.bins; + } + + public Integer getBin(Integer binNumber){ + return this.bins[binNumber - numDice]; + } + + public Integer getMaxBinIndex() { return this.maxBinIndex; } + + public Integer getMaxRoll(){ return this.maxRoll;} + + public void incrementBin(Integer binNumber){ + this.bins[binNumber - numDice]++; + } + + public void initializeDiceList(){ + for(int i = 0; i < numDice; i++){ + this.rollValues[i] = 0; + } + } + + public void initializeBins(){ + for(int i = 0; i < maxBinIndex; i++){ + this.bins[i] = 0; + } + } + + public Integer tossAndSum(){ + int sum = 0; + for(int i = 0; i < numDice; i++){ + sum += (Math.random() * 7) + 1; + } + this.incrementBin(sum); + return sum; + } + +} diff --git a/src/test/java/com/github/zipcodewilmington/DiceTest.java b/src/test/java/com/github/zipcodewilmington/DiceTest.java new file mode 100644 index 000000000..357497dd4 --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/DiceTest.java @@ -0,0 +1,88 @@ +package com.github.zipcodewilmington; + +import com.github.zipcodewilmington.casino.models.Dice; +import org.junit.Assert; +import org.junit.Test; + +public class DiceTest { + @Test + public void diceConstructorTest1() { + Dice dice = new Dice(2); + Integer actual = dice.getNumDice(); + Integer expected = 2; + + Assert.assertEquals(expected, actual); + } + + @Test + public void diceConstructorTest2() { + Dice dice = new Dice(3); + Integer expected = 18; + Integer actual = dice.getMaxRoll(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void diceConstructorTest3() { + Dice dice = new Dice(3); + Integer expected = 14; + Integer actual = dice.getMaxBinIndex(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void diceConstructorTest4() { + Dice dice = new Dice(3); + Integer expected = 3; + Integer actual = dice.getRollValues().length; + + Assert.assertEquals(expected, actual); + } + + @Test + public void diceConstructorTest5() { + Dice dice = new Dice(2); + Integer expected = 10; + Integer actual = dice.getBins().length; + + Assert.assertEquals(expected, actual); + } + + @Test + public void diceConstructorTest6() { + Dice dice = new Dice(2); + Integer[] expected = {0, 0}; + Integer[] actual = dice.getRollValues(); + + Assert.assertArrayEquals(expected, actual); + } + + @Test + public void diceConstructorTest7(){ + Dice dice = new Dice(2); + Integer[] expected = {0,0,0,0,0,0,0,0,0}; + Integer[] actual = dice.getBins(); + + Assert.assertArrayEquals(expected, actual); + } + + @Test + public void getBinQuantityTest(){ + Dice dice = new Dice(2); + dice.tossAndSum(); + Integer[] bins = dice.getBins(); + Integer actual = 0; + for(int i = 2; i < dice.getMaxBinIndex(); i++){ + if(dice.getBin(i) > 0){ + actual = dice.getBin(i); + break; + } + } + Integer expected = 1; + + Assert.assertEquals(expected, actual); + } + +} From b9631bd2a8f82b3e154c35f66f5176a995ba07f3 Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 12 Jul 2021 22:18:34 -0400 Subject: [PATCH 04/48] started slots class --- .../com/github/zipcodewilmington/casino/games/slots/Slots.java | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java new file mode 100644 index 000000000..c7bfcae69 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java @@ -0,0 +1,2 @@ +package com.github.zipcodewilmington.casino.games.slots;public class Slots { +} From ef997057200376d8d7314e70be6640bec7744a10 Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 12 Jul 2021 22:19:43 -0400 Subject: [PATCH 05/48] started slots class --- .../zipcodewilmington/casino/games/slots/Slots.java | 11 ++++++++++- .../casino/games/slots/SlotsGame.java | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java index c7bfcae69..4c0543226 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java @@ -1,2 +1,11 @@ -package com.github.zipcodewilmington.casino.games.slots;public class Slots { +package com.github.zipcodewilmington.casino.games.slots; + +import java.util.List; + +public class Slots { + private static String[] slotItems = {"Peach", "Cherry", "Diamond", "Plum", "Seven", "Nine"}; + String[][] slots = new String[3][3]; + public void spinSlots(){ + } + } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java index 78d2fca4d..2f3740d50 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java @@ -5,4 +5,5 @@ */ public class SlotsGame { + } From d23c2a2b97cd4652d1ff98bba7bb0850bec1ce5d Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 12 Jul 2021 21:58:29 -0400 Subject: [PATCH 06/48] edited GameInterface --- .../casino/GameInterface.java | 19 ++++++++++++++++++- .../casino/games/slots/SlotsGame.java | 3 ++- .../casino/games/slots/SlotsPlayer.java | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java index 9873f1ed9..4f5e662c5 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java +++ b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java @@ -1,7 +1,8 @@ package com.github.zipcodewilmington.casino; /** - * Created by leon on 7/21/2020. + * Author: Nathan + * Date: 7/12/21 */ public interface GameInterface extends Runnable { /** @@ -20,4 +21,20 @@ public interface GameInterface extends Runnable { * specifies how the game will run */ void run(); + + /** + * Calculate player's winning payout amount of bet x multiplier + * @return (double) amount of money winnings + */ + Double calculateWinnings(Double betAmount); + + /** + * Subtract the bet amount from player's balance + */ + void subtractBetFromBalance(Double betAmount); + + /** + * Add winnings amount to player's balance + */ + void addMoneyToBalance(PlayerInterface Player, Double winnings); } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java index 8cb20c787..78d2fca4d 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java @@ -1,7 +1,8 @@ package com.github.zipcodewilmington.casino.games.slots; /** - * Created by leon on 7/21/2020. + * Created by Nathan on 7/12/21 */ public class SlotsGame { + } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsPlayer.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsPlayer.java index f89ebd7f5..c5c6df9d3 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsPlayer.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsPlayer.java @@ -4,4 +4,5 @@ * Created by leon on 7/21/2020. */ public class SlotsPlayer { + } \ No newline at end of file From e14aeb859c09a310c3641bb0d2df61fd7d6e33ea Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 12 Jul 2021 22:18:34 -0400 Subject: [PATCH 07/48] started slots class --- .../com/github/zipcodewilmington/casino/games/slots/Slots.java | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java new file mode 100644 index 000000000..c7bfcae69 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java @@ -0,0 +1,2 @@ +package com.github.zipcodewilmington.casino.games.slots;public class Slots { +} From d937b7e4a86df65dcd9a0a195994e5db2cdea251 Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 12 Jul 2021 22:19:43 -0400 Subject: [PATCH 08/48] started slots class --- .../zipcodewilmington/casino/games/slots/Slots.java | 11 ++++++++++- .../casino/games/slots/SlotsGame.java | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java index c7bfcae69..4c0543226 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java @@ -1,2 +1,11 @@ -package com.github.zipcodewilmington.casino.games.slots;public class Slots { +package com.github.zipcodewilmington.casino.games.slots; + +import java.util.List; + +public class Slots { + private static String[] slotItems = {"Peach", "Cherry", "Diamond", "Plum", "Seven", "Nine"}; + String[][] slots = new String[3][3]; + public void spinSlots(){ + } + } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java index 78d2fca4d..2f3740d50 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java @@ -5,4 +5,5 @@ */ public class SlotsGame { + } From 0e6255e67595fadbafac9fd03c3837b354cc09c6 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 12 Jul 2021 23:56:46 -0400 Subject: [PATCH 09/48] Started BlackJack, needs a lot of reform --- .../casino/games/blackjack/BlackJack.java | 97 +++++++++++++++++++ .../zipcodewilmington/BlackJackTest.java | 40 ++++++++ 2 files changed, 137 insertions(+) create mode 100644 src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java create mode 100644 src/test/java/com/github/zipcodewilmington/BlackJackTest.java diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java new file mode 100644 index 000000000..48beee802 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java @@ -0,0 +1,97 @@ +package com.github.zipcodewilmington.casino.games.blackjack; + +import com.github.zipcodewilmington.casino.CasinoAccount; +import com.github.zipcodewilmington.casino.GameInterface; +import com.github.zipcodewilmington.casino.PlayerInterface; +import com.github.zipcodewilmington.casino.models.Card; + +import java.util.*; + +public class BlackJack implements GameInterface, PlayerInterface { + Card card = new Card(); + List playersHand; + List dealersHand; + Deque deckOfCards = new LinkedList<>(generateNewDeck(52)); + + public BlackJack () { + this.playersHand = new ArrayList<>(); + this.dealersHand = new ArrayList<>(); + } + + public List generateNewDeck (Integer numberOfCards) { + card.createDeck(numberOfCards); + card.polishDeck(); + card.shuffleDeck(); + return card.getCardPool(); + } + + public List givePlayerCard () { + Integer valueOfCard = deckOfCards.pop(); + this.playersHand.add(valueOfCard); + return this.playersHand; + } + + public Integer playersCurrentValue () { + Integer sum = 0; + for (int i = 0; i < this.playersHand.size(); i++) { + sum += this.playersHand.get(i); + } + return sum; + } + + public List getPlayersHand() { + return playersHand; + } + + public void setPlayersHand(List playersHand) { + this.playersHand = playersHand; + } + + public List getDealersHand() { + return dealersHand; + } + + public void setDealersHand(List dealersHand) { + this.dealersHand = dealersHand; + } + + @Override + public void add(PlayerInterface player) { + + } + + @Override + public void remove(PlayerInterface player) { + + } + + @Override + public void run() { + + } + + @Override + public Double calculateWinnings(Double betAmount) { + return null; + } + + @Override + public void subtractBetFromBalance(Double betAmount) { + + } + + @Override + public void addMoneyToBalance(PlayerInterface Player, Double winnings) { + + } + + @Override + public CasinoAccount getArcadeAccount() { + return null; + } + + @Override + public SomeReturnType play() { + return null; + } +} diff --git a/src/test/java/com/github/zipcodewilmington/BlackJackTest.java b/src/test/java/com/github/zipcodewilmington/BlackJackTest.java new file mode 100644 index 000000000..b17361a7e --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/BlackJackTest.java @@ -0,0 +1,40 @@ +package com.github.zipcodewilmington; + +import com.github.zipcodewilmington.casino.games.blackjack.BlackJack; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; + +public class BlackJackTest { + @Test + public void generateNewDeckTest() { + BlackJack bj = new BlackJack(); + Integer expected = 165; + + Integer actual1 = bj.generateNewDeck(52).size(); + List actual = bj.generateNewDeck(52); + System.out.println(actual); + + Assert.assertEquals(expected, actual1); + } + + @Test + public void givePlayerCardTest() { + BlackJack bj = new BlackJack(); + Integer expected = 2; + + bj.givePlayerCard(); + bj.givePlayerCard(); + Integer actual = bj.getPlayersHand().size(); + + System.out.println(bj.getPlayersHand()); + Assert.assertEquals(expected, actual); + } + + @Test + public void playersCurrentValueTest () { + BlackJack bj = new BlackJack(); + // Solid stopping point = need to populate array for test + } +} From b6997ba351b0bb37ae7f3f9408c2c65489e2b754 Mon Sep 17 00:00:00 2001 From: Zach Date: Tue, 13 Jul 2021 02:05:44 -0400 Subject: [PATCH 10/48] Completed Beetle.java and tests for Beetle.java --- .../casino/games/Beetle/Beetle.java | 92 ++++++++++ .../casino/games/Beetle/BeetleGame.java | 58 +++++++ .../casino/games/Beetle/BeetlePlayer.java | 4 + .../github/zipcodewilmington/BeetleTest.java | 162 ++++++++++++++++++ 4 files changed, 316 insertions(+) create mode 100644 src/main/java/com/github/zipcodewilmington/casino/games/Beetle/Beetle.java create mode 100644 src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java create mode 100644 src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetlePlayer.java create mode 100644 src/test/java/com/github/zipcodewilmington/BeetleTest.java diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/Beetle.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/Beetle.java new file mode 100644 index 000000000..56461ccc5 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/Beetle.java @@ -0,0 +1,92 @@ +package com.github.zipcodewilmington.casino.games.Beetle; + +import com.github.zipcodewilmington.casino.models.Dice; + +public class Beetle{ + private Dice dice = new Dice(1); + private Integer currentPlayer = 0; + private Integer[][] playerBeetles; + private Integer[] scoreboard; + private Integer numPlayers; + + public Beetle(Integer numPlayers){ + this.numPlayers = numPlayers; + this.playerBeetles = new Integer[numPlayers][6]; + this.scoreboard = new Integer[numPlayers]; + this.initializeBeetleCards(); + this.initializeScoreboards(); + } + + public void initializeBeetleCards(){ + for(int i = 0; i < numPlayers; i++){ + for(int j = 0; j < 6; j++){ + this.playerBeetles[i][j] = 0; + } + } + } + + public void initializeScoreboards(){ + for(int i = 0; i < numPlayers; i++){ + this.scoreboard[i] = 0; + } + } + + public Dice getDice() { + return dice; + } + + public Integer getCurrentPlayer() { + return currentPlayer; + } + + public Integer[][] getPlayerBeetles() { + return playerBeetles; + } + + public Integer getNumPlayers() { + return numPlayers; + } + + public Integer[] getPlayerCard(Integer playerNumber){ + return this.getPlayerBeetles()[playerNumber]; + } + + public void setCurrentPlayer(Integer currentPlayer) { + this.currentPlayer = currentPlayer; + } + + public void setPlayerBeetles(Integer player, Integer diceRoll) { + this.playerBeetles[player][diceRoll]++; + //return this.checkWinner(player); + } + + public void refreshBeetle(Integer player){ + this.playerBeetles[player] = new Integer[] {0, 0, 0, 0, 0, 0}; + } + + + public Boolean checkWinner(Integer player){ + if(this.beetleIsComplete(player)){ + this.scoreboard[player] += 6; + if(this.getScore(player) == 30){ + return true; + } else { + this.refreshBeetle(player); + } + } + return false; + } + + public Boolean beetleIsComplete(Integer player){ + Integer[] playerBeetle = getPlayerCard(player); + for(int i = 0; i < 6; i++){ + if(playerBeetle[i] == 0) + return false; + } + return true; + } + + public Integer getScore(Integer player){ + return this.scoreboard[player]; + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java new file mode 100644 index 000000000..6a23520c3 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java @@ -0,0 +1,58 @@ +package com.github.zipcodewilmington.casino.games.Beetle; + +import com.github.zipcodewilmington.casino.GameInterface; +import com.github.zipcodewilmington.casino.PlayerInterface; + +public class BeetleGame implements GameInterface { + private PlayerInterface[] players; + private Beetle game; + private Boolean isRunning = false; + public void add(PlayerInterface player){ + + } + + /** + * removes a player from the game + * @param player the player to be removed from the game + */ + public void remove(PlayerInterface player){ + + } + + /** + * specifies how the game will run + */ + public void run(){ + if(isRunning){ + + } + } + + /** + * Calculate player's winning payout amount of bet x multiplier + * @return (double) amount of money winnings + */ + public Double calculateWinnings(Double betAmount){ + return 0.00; + } + + /** + * Subtract the bet amount from player's balance + */ + public void subtractBetFromBalance(Double betAmount){} + + + /** + * Add winnings amount to player's balance + */ + public void addMoneyToBalance(PlayerInterface Player, Double winnings){ + + } + + public void initGame(){ + this.game = new Beetle(this.players.length); + } + + + +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetlePlayer.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetlePlayer.java new file mode 100644 index 000000000..34b4ceb45 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetlePlayer.java @@ -0,0 +1,4 @@ +package com.github.zipcodewilmington.casino.games.Beetle; + +public class BeetlePlayer { +} diff --git a/src/test/java/com/github/zipcodewilmington/BeetleTest.java b/src/test/java/com/github/zipcodewilmington/BeetleTest.java new file mode 100644 index 000000000..d1de50bd9 --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/BeetleTest.java @@ -0,0 +1,162 @@ +package com.github.zipcodewilmington; + +import com.github.zipcodewilmington.casino.games.Beetle.Beetle; +import org.junit.Assert; +import org.junit.Test; + +public class BeetleTest { + @Test + public void constructorTest1(){ + Beetle beetle = new Beetle(3); + Integer expected = 3; + Integer actual = beetle.getPlayerBeetles().length; + + Assert.assertEquals(expected, actual); + } + + @Test + public void constructorTest2(){ + Beetle beetle = new Beetle(2); + Integer expected = 6; + Integer[][] playerCards = beetle.getPlayerBeetles(); + Integer actual = playerCards[0].length; + + Assert.assertEquals(expected, actual); + } + + @Test + public void constructorTest3(){ + Beetle beetle = new Beetle(4); + Integer expected = 0; + Integer[][] playerCards = beetle.getPlayerBeetles(); + Integer actual = playerCards[0][0]; + + Assert.assertEquals(expected, actual); + } + + @Test + public void constructorTest4(){ + Beetle beetle = new Beetle(2); + Integer expected = 0; + Integer actual = beetle.getScore(0); + + Assert.assertEquals(expected, actual); + } + + @Test + public void numPlayersTest(){ + Beetle beetle = new Beetle(2); + Integer expected = 2; + Integer actual = beetle.getNumPlayers(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void setPlayerTest(){ + Beetle beetle = new Beetle(2); + Integer expected = 1; + beetle.setCurrentPlayer(1); + Integer actual = beetle.getCurrentPlayer(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void setPlayerBeetleTest(){ + Beetle beetle = new Beetle(2); + Integer expected = 1; + beetle.setPlayerBeetles(0, beetle.getDice().tossAndSum()); + Integer actual = 0; + Integer[] playerCard = beetle.getPlayerCard(0); + for(int i = 0; i < 6; i++){ + if(playerCard[i] > 0){ + actual++; + } + } + Assert.assertEquals(expected, actual); + } + + @Test + public void beetleIsCompleteTest1(){ + Beetle beetle = new Beetle(2); + Boolean expected = true; + for(int i = 0; i < 6; i++) { + beetle.setPlayerBeetles(0, i); + } + Boolean actual = beetle.beetleIsComplete(0); + + Assert.assertEquals(expected, actual); + } + + @Test + public void beetleIsCompleteTest2(){ + Beetle beetle = new Beetle(2); + Boolean expected = false; + Boolean actual = beetle.beetleIsComplete(0); + + Assert.assertEquals(expected, actual); + } + + @Test + public void checkWinnerTest1(){ + Beetle beetle = new Beetle(2); + Boolean actual = false; + for(int i = 0; i < 5; i++){ + for(int j = 0; j < 6; j++){ + beetle.setPlayerBeetles(0, j); + } + actual = beetle.checkWinner(0); + } + Assert.assertTrue(actual); + } + + @Test + public void checkWinnerTest2(){ + Beetle beetle = new Beetle(2); + Boolean actual = false; + for(int i = 0; i < 4; i++){ + for(int j = 0; j < 6; j++){ + beetle.setPlayerBeetles(0, j); + } + actual = beetle.checkWinner(0); + } + Assert.assertFalse(actual); + } + + @Test + public void getScoreTest1(){ + Beetle beetle = new Beetle(2); + for(int j = 0; j < 6; j++){ + beetle.setPlayerBeetles(0, j); + } + beetle.checkWinner(0); + Integer expected = 6; + Integer actual = beetle.getScore(0); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getScoreTest2(){ + Beetle beetle = new Beetle(2); + + Integer expected = 0; + Integer actual = beetle.getScore(0); + + Assert.assertEquals(expected, actual); + } + + @Test + public void refreshBeetleTest(){ + Beetle beetle = new Beetle(2); + for(int j = 0; j < 6; j++){ + beetle.setPlayerBeetles(0, j); + } + beetle.refreshBeetle(0); + Integer[] actual = beetle.getPlayerCard(0); + Integer[] expected = new Integer[] {0, 0, 0, 0, 0, 0}; + + Assert.assertArrayEquals(actual, expected); + } +} From 6ddad3f1e2c5caffa7fa58bbbea2d41ed5ddba8f Mon Sep 17 00:00:00 2001 From: Dipinti Date: Tue, 13 Jul 2021 06:13:26 -0400 Subject: [PATCH 11/48] Player.java ready --- .../zipcodewilmington/casino/Player.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/com/github/zipcodewilmington/casino/Player.java diff --git a/src/main/java/com/github/zipcodewilmington/casino/Player.java b/src/main/java/com/github/zipcodewilmington/casino/Player.java new file mode 100644 index 000000000..f81eef273 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/Player.java @@ -0,0 +1,42 @@ +package com.github.zipcodewilmington.casino; + +public class Player{ + + String name; + Double balance; + Double currentBet = 0.0; + + public Player(String name, Double initialDeposit) { + this.name = name; + this.balance = initialDeposit; + } + + + public String getName() { + return name; + } + + + public Double getBalance() { + return balance; + } + + private void setCurrentBet(Double currentBet) { + this.currentBet = currentBet; + } + + public void setBalance(Double deposit) { + this.balance = balance + deposit; + } + + + public Double makeBet(Double betAmount) { + currentBet = betAmount; + balance = balance - currentBet; + return currentBet; + } + + private Double getCurrentBet() { + return currentBet; + } +} From 76d125f90c59fd8f53047c7f4b2d723af6fbade9 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 10:40:02 -0400 Subject: [PATCH 12/48] Have to reform cards, updating BlackJack --- .../github/zipcodewilmington/casino/models/Card.java | 9 +++++---- .../java/com/github/zipcodewilmington/CardsTest.java | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/models/Card.java b/src/main/java/com/github/zipcodewilmington/casino/models/Card.java index 3464cec6f..091142af6 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/models/Card.java +++ b/src/main/java/com/github/zipcodewilmington/casino/models/Card.java @@ -12,6 +12,9 @@ public Card () { this.createDeck(numberOfCards); } + // Alter the loop to provide the correct amount of 10's + // Jack/Queen/King + // Should have 16 - 10 values in a 52 deck public List createDeck (Integer numberOfCards) { for (int i = 0; i <= 4; i++) { @@ -22,18 +25,16 @@ public List createDeck (Integer numberOfCards) { return this.cardPool; } - public List polishDeck () { + public void polishDeck () { for (int i = 0; i < this.cardPool.size(); i++) { if (this.cardPool.get(i) > 11) { this.cardPool.set(i, 10); } } - return this.cardPool; } - public List shuffleDeck () { + public void shuffleDeck () { Collections.shuffle(this.cardPool); - return this.cardPool; } public List getCardPool() { diff --git a/src/test/java/com/github/zipcodewilmington/CardsTest.java b/src/test/java/com/github/zipcodewilmington/CardsTest.java index 269c3b91e..d5e0d1e93 100644 --- a/src/test/java/com/github/zipcodewilmington/CardsTest.java +++ b/src/test/java/com/github/zipcodewilmington/CardsTest.java @@ -33,18 +33,19 @@ public void polishDeckTest () { Card card = new Card(); card.createDeck(52); - List result = card.polishDeck(); - - System.out.println(result); + card.polishDeck(); + System.out.println(card.getCardPool().size()); + System.out.println(card.getCardPool()); +// System.out.println(result); } @Test public void shuffleDeckTest () { Card card = new Card(); - List result = card.shuffleDeck(); +// List result = card.shuffleDeck(); - System.out.println(result); // Visual test +// System.out.println(result); // Visual test } @Test From bd973acff53dab718c3a6a8fa530da1e39bc518a Mon Sep 17 00:00:00 2001 From: Zach Date: Tue, 13 Jul 2021 13:38:29 -0400 Subject: [PATCH 13/48] Ready 2 Merge --- .../casino/games/Beetle/BeetleGame.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java index 6a23520c3..2f21ffe7d 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java @@ -3,12 +3,15 @@ import com.github.zipcodewilmington.casino.GameInterface; import com.github.zipcodewilmington.casino.PlayerInterface; +import java.util.ArrayList; + public class BeetleGame implements GameInterface { - private PlayerInterface[] players; + private ArrayList players = new ArrayList(); private Beetle game; private Boolean isRunning = false; + private PlayerInterface player; public void add(PlayerInterface player){ - + players.add(player); } /** @@ -16,7 +19,7 @@ public void add(PlayerInterface player){ * @param player the player to be removed from the game */ public void remove(PlayerInterface player){ - + players.remove(player); } /** @@ -39,7 +42,9 @@ public Double calculateWinnings(Double betAmount){ /** * Subtract the bet amount from player's balance */ - public void subtractBetFromBalance(Double betAmount){} + public void subtractBetFromBalance(Double betAmount){ + + } /** From 52b857aab0889efaded14679c06001af0b617db6 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 13 Jul 2021 13:38:41 -0400 Subject: [PATCH 14/48] Take this shit --- .../casino/GameInterface.java | 1 + .../casino/games/slots/Slots.java | 56 ++++++++++++++++++- .../casino/games/slots/SlotsGame.java | 37 +++++++++++- .../github/zipcodewilmington/SlotsTest.java | 35 ++++++++++++ 4 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 src/test/java/com/github/zipcodewilmington/SlotsTest.java diff --git a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java index 4f5e662c5..4f2fc095d 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java +++ b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java @@ -37,4 +37,5 @@ public interface GameInterface extends Runnable { * Add winnings amount to player's balance */ void addMoneyToBalance(PlayerInterface Player, Double winnings); + } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java index 4c0543226..5e0d02d54 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java @@ -3,9 +3,59 @@ import java.util.List; public class Slots { - private static String[] slotItems = {"Peach", "Cherry", "Diamond", "Plum", "Seven", "Nine"}; - String[][] slots = new String[3][3]; - public void spinSlots(){ + private static final String[] slotItems = {"Peach", "Cherry", "Diamond", "Plum", "Seven", "Nine"}; + private String[][] slots = new String[3][3]; + + public Slots(){ + this.slots = new String[][] { + {"Peach", "Cherry", "Diamond"}, + {"Diamond", "Plum", "Nine"}, + {"Seven", "Peach", "Diamond"}}; + } + + public String[][] getSlots() { + return slots; } + + +// public void spinSlots(){ +// for(String[] slot: slots){ +// slot[0] = randomSlotItem(); +// slot[1] = randomSlotItem(); +// slot[2] = ramdomSlotItem(); +// } +// } + + public static String ramdomSlotItem(){ + int input = (int) ((Math.random() * (7 - 1)) + 1); + String result; + switch(input){ + case 1: + result = slotItems[0]; + break; + case 2: + result = slotItems[1]; + break; + case 3: + result = slotItems[2]; + break; + case 4: + result = slotItems[3]; + break; + case 5: + result = slotItems[4]; + break; + case 6: + result = slotItems[5]; + break; + default: + throw new IllegalStateException("Unexpected value: " + input); + } + return result; + } + + + + } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java index 2f3740d50..3a64e690b 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java @@ -1,9 +1,44 @@ package com.github.zipcodewilmington.casino.games.slots; +import com.github.zipcodewilmington.casino.GameInterface; +import com.github.zipcodewilmington.casino.PlayerInterface; + /** * Created by Nathan on 7/12/21 */ -public class SlotsGame { +public class SlotsGame implements GameInterface { + private static String[] slotItems = {"Peach", "Cherry", "Diamond", "Plum", "Seven", "Nine"}; + private String[][] slots = new String[3][3]; + + + + @Override + public void add(PlayerInterface player) { + + } + + @Override + public void remove(PlayerInterface player) { + + } + + @Override + public void run() { + + } + + @Override + public Double calculateWinnings(Double betAmount) { + return null; + } + + @Override + public void subtractBetFromBalance(Double betAmount) { + + } + @Override + public void addMoneyToBalance(PlayerInterface Player, Double winnings) { + } } diff --git a/src/test/java/com/github/zipcodewilmington/SlotsTest.java b/src/test/java/com/github/zipcodewilmington/SlotsTest.java new file mode 100644 index 000000000..0dc8cd614 --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/SlotsTest.java @@ -0,0 +1,35 @@ +package com.github.zipcodewilmington; + +import com.github.zipcodewilmington.casino.games.slots.Slots; +import org.junit.Assert; +import org.junit.Test; + +public class SlotsTest { + + @Test + public void slotConstructorTest(){ + //given + String[][] expected = { + {"Peach", "Cherry", "Diamond"}, + {"Diamond", "Plum", "Nine"}, + {"Seven", "Peach", "Diamond"}}; + //when + Slots slot = new Slots(); + String[][] retrieved = slot.getSlots(); + //then + Assert.assertEquals(expected, retrieved); + } + + @Test + public void randomItemTest(){ + //given + String[] given = {"Peach", "Cherry", "Diamond"}; + String[] retrieved = new String[3]; + //when + for(String element: retrieved){ + element = Slots.ramdomSlotItem(); //Not updating retrieved + } + //then + Assert.assertFalse(given.equals(retrieved)); + } +} From 151543fd6852530bcb8bec6e00a2aaaccb0da25d Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 13 Jul 2021 15:10:45 -0400 Subject: [PATCH 15/48] SLOTS SLOTS SLOTS --- .../casino/GameInterface.java | 2 +- .../casino/games/Beetle/BeetleGame.java | 4 ++-- .../casino/games/blackjack/BlackJack.java | 2 +- .../casino/games/slots/Slots.java | 17 ++++++++++------- .../casino/games/slots/SlotsGame.java | 2 +- .../github/zipcodewilmington/SlotsTest.java | 18 +++++++++++++++--- 6 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java index 4f2fc095d..1e825b192 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java +++ b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java @@ -26,7 +26,7 @@ public interface GameInterface extends Runnable { * Calculate player's winning payout amount of bet x multiplier * @return (double) amount of money winnings */ - Double calculateWinnings(Double betAmount); + Double calculateWinnings(Double multiplier, Double betAmount); /** * Subtract the bet amount from player's balance diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java index 2f21ffe7d..3a889e300 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java @@ -35,7 +35,7 @@ public void run(){ * Calculate player's winning payout amount of bet x multiplier * @return (double) amount of money winnings */ - public Double calculateWinnings(Double betAmount){ + public Double calculateWinnings(Double multiplier, Double betAmount){ return 0.00; } @@ -55,7 +55,7 @@ public void addMoneyToBalance(PlayerInterface Player, Double winnings){ } public void initGame(){ - this.game = new Beetle(this.players.length); + this.game = new Beetle(this.players.size()); } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java index 48beee802..9b0abd156 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java @@ -71,7 +71,7 @@ public void run() { } @Override - public Double calculateWinnings(Double betAmount) { + public Double calculateWinnings(Double multiplier, Double betAmount) { return null; } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java index 5e0d02d54..b91b62784 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java @@ -1,10 +1,13 @@ package com.github.zipcodewilmington.casino.games.slots; + +import java.util.ArrayList; import java.util.List; public class Slots { private static final String[] slotItems = {"Peach", "Cherry", "Diamond", "Plum", "Seven", "Nine"}; private String[][] slots = new String[3][3]; + private List slotsList = new ArrayList<>(); public Slots(){ this.slots = new String[][] { @@ -18,14 +21,14 @@ public String[][] getSlots() { } + public void spinSlots(){ -// public void spinSlots(){ -// for(String[] slot: slots){ -// slot[0] = randomSlotItem(); -// slot[1] = randomSlotItem(); -// slot[2] = ramdomSlotItem(); -// } -// } + for (int a = 0; a < 3; a++) { + this.slots[a][0] = ramdomSlotItem(); + this.slots[a][1] = ramdomSlotItem(); + this.slots[a][2] = ramdomSlotItem(); + } + } public static String ramdomSlotItem(){ int input = (int) ((Math.random() * (7 - 1)) + 1); diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java index 3a64e690b..81a36ff91 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java @@ -28,7 +28,7 @@ public void run() { } @Override - public Double calculateWinnings(Double betAmount) { + public Double calculateWinnings(Double multiplier, Double betAmount) { return null; } diff --git a/src/test/java/com/github/zipcodewilmington/SlotsTest.java b/src/test/java/com/github/zipcodewilmington/SlotsTest.java index 0dc8cd614..9dfd492f6 100644 --- a/src/test/java/com/github/zipcodewilmington/SlotsTest.java +++ b/src/test/java/com/github/zipcodewilmington/SlotsTest.java @@ -24,12 +24,24 @@ public void slotConstructorTest(){ public void randomItemTest(){ //given String[] given = {"Peach", "Cherry", "Diamond"}; - String[] retrieved = new String[3]; + String[] retrieved = {"Peach", "Cherry", "Diamond"}; //when - for(String element: retrieved){ - element = Slots.ramdomSlotItem(); //Not updating retrieved + for (int i = 0; i < retrieved.length; i++) { + retrieved[i] = Slots.ramdomSlotItem(); } //then Assert.assertFalse(given.equals(retrieved)); } + + @Test + public void spinSlotsTest(){ + //given + Slots slotMachine = new Slots(); + String[][] given = slotMachine.getSlots(); + //when + slotMachine.spinSlots(); + String[][] retrieved = slotMachine.getSlots(); + //then + Assert.assertFalse(given.equals(retrieved)); + } } From c920eee14a51bf4333bea092628bca61c0e4c5e4 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 15:11:34 -0400 Subject: [PATCH 16/48] 21 21 21 --- .../casino/GameInterface.java | 2 +- .../casino/games/Beetle/BeetleGame.java | 4 +- .../casino/games/blackjack/BlackJack.java | 33 +++++++++++---- .../casino/games/slots/SlotsGame.java | 2 +- .../zipcodewilmington/casino/models/Card.java | 27 ++++-------- .../zipcodewilmington/BlackJackTest.java | 42 +++++++++++++++++-- .../github/zipcodewilmington/CardsTest.java | 15 ++++--- 7 files changed, 85 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java index 4f2fc095d..1e825b192 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java +++ b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java @@ -26,7 +26,7 @@ public interface GameInterface extends Runnable { * Calculate player's winning payout amount of bet x multiplier * @return (double) amount of money winnings */ - Double calculateWinnings(Double betAmount); + Double calculateWinnings(Double multiplier, Double betAmount); /** * Subtract the bet amount from player's balance diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java index 2f21ffe7d..3a889e300 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java @@ -35,7 +35,7 @@ public void run(){ * Calculate player's winning payout amount of bet x multiplier * @return (double) amount of money winnings */ - public Double calculateWinnings(Double betAmount){ + public Double calculateWinnings(Double multiplier, Double betAmount){ return 0.00; } @@ -55,7 +55,7 @@ public void addMoneyToBalance(PlayerInterface Player, Double winnings){ } public void initGame(){ - this.game = new Beetle(this.players.length); + this.game = new Beetle(this.players.size()); } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java index 48beee802..7b7278932 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java @@ -8,20 +8,19 @@ import java.util.*; public class BlackJack implements GameInterface, PlayerInterface { - Card card = new Card(); List playersHand; List dealersHand; - Deque deckOfCards = new LinkedList<>(generateNewDeck(52)); + Deque deckOfCards; + Double betAmount; // Equal to user input public BlackJack () { this.playersHand = new ArrayList<>(); this.dealersHand = new ArrayList<>(); + this.deckOfCards = new ArrayDeque<>(generateNewDeck()); } - public List generateNewDeck (Integer numberOfCards) { - card.createDeck(numberOfCards); - card.polishDeck(); - card.shuffleDeck(); + public List generateNewDeck () { + Card card = new Card(); return card.getCardPool(); } @@ -31,7 +30,14 @@ public List givePlayerCard () { return this.playersHand; } + public List giveDealerCard () { + Integer valueOfCard = deckOfCards.pop(); + this.dealersHand.add(valueOfCard); + return this.dealersHand; + } + public Integer playersCurrentValue () { + givePlayerCard(); Integer sum = 0; for (int i = 0; i < this.playersHand.size(); i++) { sum += this.playersHand.get(i); @@ -39,6 +45,19 @@ public Integer playersCurrentValue () { return sum; } + public Integer dealersCurrentValue () { + giveDealerCard(); + Integer sum = 0; + for (int i = 0; i < this.dealersHand.size(); i++) { + sum += this.dealersHand.get(i); + } + return sum; + } + + public void playerBroke21 () { + + } + public List getPlayersHand() { return playersHand; } @@ -71,7 +90,7 @@ public void run() { } @Override - public Double calculateWinnings(Double betAmount) { + public Double calculateWinnings(Double multiplier, Double betAmount) { return null; } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java index 3a64e690b..81a36ff91 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java @@ -28,7 +28,7 @@ public void run() { } @Override - public Double calculateWinnings(Double betAmount) { + public Double calculateWinnings(Double multiplier, Double betAmount) { return null; } diff --git a/src/main/java/com/github/zipcodewilmington/casino/models/Card.java b/src/main/java/com/github/zipcodewilmington/casino/models/Card.java index 091142af6..2a4def12d 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/models/Card.java +++ b/src/main/java/com/github/zipcodewilmington/casino/models/Card.java @@ -4,28 +4,27 @@ public class Card { List cardPool; - Integer numberOfCards; // The deck will be made of - public Card () { - this.numberOfCards = 52; + public Card() { this.cardPool = new ArrayList<>(); - this.createDeck(numberOfCards); + this.createDeck(); + this.polishDeck(); + this.shuffleDeck(); } // Alter the loop to provide the correct amount of 10's // Jack/Queen/King // Should have 16 - 10 values in a 52 deck - public List createDeck (Integer numberOfCards) { - for (int i = 0; i <= 4; i++) { - for (int j = 2; j < (numberOfCards / 4); j++) { + public void createDeck() { + for (int i = 0; i < 4; i++) { + for (int j = 2; j < 15; j++) { this.cardPool.add(j); } } - return this.cardPool; } - public void polishDeck () { + public void polishDeck() { for (int i = 0; i < this.cardPool.size(); i++) { if (this.cardPool.get(i) > 11) { this.cardPool.set(i, 10); @@ -33,7 +32,7 @@ public void polishDeck () { } } - public void shuffleDeck () { + public void shuffleDeck() { Collections.shuffle(this.cardPool); } @@ -44,12 +43,4 @@ public List getCardPool() { public void setCardPool(List cardPool) { this.cardPool = cardPool; } - - public Integer getNumberOfCards() { - return numberOfCards; - } - - public void setNumberOfCards(Integer numberOfCards) { - this.numberOfCards = numberOfCards; - } } diff --git a/src/test/java/com/github/zipcodewilmington/BlackJackTest.java b/src/test/java/com/github/zipcodewilmington/BlackJackTest.java index b17361a7e..60ae907a9 100644 --- a/src/test/java/com/github/zipcodewilmington/BlackJackTest.java +++ b/src/test/java/com/github/zipcodewilmington/BlackJackTest.java @@ -12,8 +12,8 @@ public void generateNewDeckTest() { BlackJack bj = new BlackJack(); Integer expected = 165; - Integer actual1 = bj.generateNewDeck(52).size(); - List actual = bj.generateNewDeck(52); + Integer actual1 = bj.generateNewDeck().size(); + List actual = bj.generateNewDeck(); System.out.println(actual); Assert.assertEquals(expected, actual1); @@ -32,9 +32,45 @@ public void givePlayerCardTest() { Assert.assertEquals(expected, actual); } + @Test + public void giveDealerCardTest () { + BlackJack bj = new BlackJack(); + Integer expected = 2; + + bj.giveDealerCard(); + bj.giveDealerCard(); + Integer actual = bj.getDealersHand().size(); + + System.out.println(bj.getDealersHand()); + Assert.assertEquals(expected, actual); + } + @Test public void playersCurrentValueTest () { BlackJack bj = new BlackJack(); - // Solid stopping point = need to populate array for test + List expected = bj.getPlayersHand(); + + bj.playersCurrentValue(); + Integer actual = bj.playersCurrentValue(); + + System.out.println(expected); + System.out.println(actual); + } + + @Test + public void dealersCurrentValueTest () { + BlackJack bj = new BlackJack(); + List expected = bj.getDealersHand(); + + bj.dealersCurrentValue(); + Integer actual = bj.dealersCurrentValue(); + + System.out.println(expected); + System.out.println(actual); + } + + @Test + public void playerBroke21Test () { + } } diff --git a/src/test/java/com/github/zipcodewilmington/CardsTest.java b/src/test/java/com/github/zipcodewilmington/CardsTest.java index d5e0d1e93..490a5e821 100644 --- a/src/test/java/com/github/zipcodewilmington/CardsTest.java +++ b/src/test/java/com/github/zipcodewilmington/CardsTest.java @@ -12,7 +12,7 @@ public void constructorTest () { Integer expected = 52; Card card = new Card(); - Integer actual = card.getNumberOfCards(); + Integer actual = card.getCardPool().size(); Assert.assertEquals(expected, actual); } @@ -20,19 +20,19 @@ public void constructorTest () { @Test public void createDeckTest () { // Given - Card card = new Card(); - Integer expected = 52; - Integer actual = card.getNumberOfCards(); + + Card card = new Card(); + Integer actual = card.getCardPool().size(); Assert.assertEquals(expected, actual); + } @Test public void polishDeckTest () { Card card = new Card(); - card.createDeck(52); card.polishDeck(); System.out.println(card.getCardPool().size()); System.out.println(card.getCardPool()); @@ -43,9 +43,8 @@ public void polishDeckTest () { public void shuffleDeckTest () { Card card = new Card(); -// List result = card.shuffleDeck(); - -// System.out.println(result); // Visual test + System.out.println(card.getCardPool().size()); + System.out.println(card.getCardPool()); // Visual test } @Test From 38df35b23aa548e6e989c5f5330cbc9b86f79aeb Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 15:39:58 -0400 Subject: [PATCH 17/48] Setting up my branch --- .../casino/games/blackjack/BlackJack.java | 18 +++++++++++++++++- .../zipcodewilmington/BlackJackTest.java | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java index 7b7278932..4e08ad9dc 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java @@ -55,7 +55,23 @@ public Integer dealersCurrentValue () { } public void playerBroke21 () { - + if (playersCurrentValue() > 21) { + subtractBetFromBalance(betAmount); + } + } + + public void playerBlackJack () { + if (playersCurrentValue() == 21) { + calculateWinnings(3.0, betAmount); + } + } + + public void dealerConditions () { + if (dealersCurrentValue() > 21) { + calculateWinnings(2.0, betAmount); //Players winnings, not dealers (Player won) + } else if (dealersCurrentValue() <= 21 && dealersCurrentValue() > playersCurrentValue()) { + subtractBetFromBalance(betAmount); + } } public List getPlayersHand() { diff --git a/src/test/java/com/github/zipcodewilmington/BlackJackTest.java b/src/test/java/com/github/zipcodewilmington/BlackJackTest.java index 60ae907a9..5c84f980e 100644 --- a/src/test/java/com/github/zipcodewilmington/BlackJackTest.java +++ b/src/test/java/com/github/zipcodewilmington/BlackJackTest.java @@ -70,7 +70,7 @@ public void dealersCurrentValueTest () { } @Test - public void playerBroke21Test () { + public void playerBroke21orBlackJackTest () { } } From 9c740362444bd7048540510c169f33c068d313af Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 16:06:17 -0400 Subject: [PATCH 18/48] what --- .../zipcodewilmington/casino/games/blackjack/BlackJack.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java index 9b0abd156..b22c4c04e 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java @@ -39,6 +39,8 @@ public Integer playersCurrentValue () { return sum; } + public void ahhWork () {} + public List getPlayersHand() { return playersHand; } From 079ecb13b6288d28cd0ed02e05001bd99d36c6b1 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 16:26:38 -0400 Subject: [PATCH 19/48] pushin for the cushion --- .../zipcodewilmington/casino/games/blackjack/BlackJack.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java index 48beee802..da3e91336 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java @@ -39,6 +39,10 @@ public Integer playersCurrentValue () { return sum; } + public void pleaseWork () { + + } + public List getPlayersHand() { return playersHand; } From 698fc050edba26fb1341c05a612dd16fc1b01793 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 13 Jul 2021 16:32:38 -0400 Subject: [PATCH 20/48] Solved some problems --- .../casino/games/slots/Slots.java | 42 +++++++------------ .../github/zipcodewilmington/SlotsTest.java | 29 +++++++++++++ 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java index b91b62784..dec1ba30d 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java @@ -2,6 +2,8 @@ import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; public class Slots { @@ -20,44 +22,32 @@ public String[][] getSlots() { return slots; } + public void setSlots(String[][] slots) { + this.slots = slots; + } public void spinSlots(){ - + String[][] newSlot = new String[3][3]; for (int a = 0; a < 3; a++) { - this.slots[a][0] = ramdomSlotItem(); - this.slots[a][1] = ramdomSlotItem(); - this.slots[a][2] = ramdomSlotItem(); + newSlot[a][0] = ramdomSlotItem(); + newSlot[a][1] = ramdomSlotItem(); + newSlot[a][2] = ramdomSlotItem(); } + setSlots(newSlot); } public static String ramdomSlotItem(){ int input = (int) ((Math.random() * (7 - 1)) + 1); String result; - switch(input){ - case 1: - result = slotItems[0]; - break; - case 2: - result = slotItems[1]; - break; - case 3: - result = slotItems[2]; - break; - case 4: - result = slotItems[3]; - break; - case 5: - result = slotItems[4]; - break; - case 6: - result = slotItems[5]; - break; - default: - throw new IllegalStateException("Unexpected value: " + input); - } + result = slotItems[input -1]; return result; } + public static void findWinnings(){ + //HashMap; + + } + diff --git a/src/test/java/com/github/zipcodewilmington/SlotsTest.java b/src/test/java/com/github/zipcodewilmington/SlotsTest.java index 9dfd492f6..97f2fa7c5 100644 --- a/src/test/java/com/github/zipcodewilmington/SlotsTest.java +++ b/src/test/java/com/github/zipcodewilmington/SlotsTest.java @@ -20,6 +20,35 @@ public void slotConstructorTest(){ Assert.assertEquals(expected, retrieved); } + @Test + public void setSlotTest(){ + //given + Slots slot = new Slots(); + String[][] given = { + {"Cherry", "Cherry", "Cherry"}, + {"Diamond", "Plum", "Nine"}, + {"Seven", "Peach", "Diamond"}}; + //when + slot.setSlots(given); + String[][] retrieved = slot.getSlots(); + //then + Assert.assertEquals(given,retrieved); + } + + @Test + public void getSlotTest(){ + //given + String[][] expected = { + {"Peach", "Cherry", "Diamond"}, + {"Diamond", "Plum", "Nine"}, + {"Seven", "Peach", "Diamond"}}; + //when + Slots slot = new Slots(); + String[][] retrieved = slot.getSlots(); + //then + Assert.assertEquals(expected, retrieved); + } + @Test public void randomItemTest(){ //given From 13561fdffd5a7624fc80edcf7943c6a78cb9e08f Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 16:37:02 -0400 Subject: [PATCH 21/48] uhh --- src/test/java/com/github/zipcodewilmington/BlackJackTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/com/github/zipcodewilmington/BlackJackTest.java b/src/test/java/com/github/zipcodewilmington/BlackJackTest.java index b17361a7e..a81fc753d 100644 --- a/src/test/java/com/github/zipcodewilmington/BlackJackTest.java +++ b/src/test/java/com/github/zipcodewilmington/BlackJackTest.java @@ -36,5 +36,8 @@ public void givePlayerCardTest() { public void playersCurrentValueTest () { BlackJack bj = new BlackJack(); // Solid stopping point = need to populate array for test + bj.givePlayerCard(); + bj.givePlayerCard(); + System.out.println(bj.playersCurrentValue()); } } From 96fa77edc8460ee7944262bd0dda2ed4373b8615 Mon Sep 17 00:00:00 2001 From: Zach Date: Tue, 13 Jul 2021 16:52:43 -0400 Subject: [PATCH 22/48] testing --- .../zipcodewilmington/casino/games/Beetle/BeetleGame.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java index 3a889e300..ff6f24938 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java @@ -31,6 +31,9 @@ public void run(){ } } + public String test(){ + return ""; + } /** * Calculate player's winning payout amount of bet x multiplier * @return (double) amount of money winnings From c4d34c35bdfa815b819a756511e3bc21e1bcadd8 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 13 Jul 2021 16:53:45 -0400 Subject: [PATCH 23/48] Edited BeetleGame --- .../casino/games/Beetle/BeetleGame.java | 2 +- .../zipcodewilmington/casino/games/slots/Slots.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java index ff6f24938..a00b9b9c1 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java @@ -32,7 +32,7 @@ public void run(){ } public String test(){ - return ""; + return "NATHAN WAS HERE"; } /** * Calculate player's winning payout amount of bet x multiplier diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java index dec1ba30d..970289ee9 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java @@ -44,7 +44,16 @@ public static String ramdomSlotItem(){ } public static void findWinnings(){ - //HashMap; + HashMap winningLines = new HashMap<>(); + winningLines.put(1,"Lose"); + winningLines.put(2,"Lose"); + winningLines.put(3,"Lose"); + winningLines.put(4,"Lose"); + winningLines.put(5,"Lose"); + winningLines.put(6,"Lose"); + winningLines.put(7,"Lose"); + + } From b7067a74c00ebe7f2eab99378fa02447fa4365c3 Mon Sep 17 00:00:00 2001 From: Jarryd Stamatelos Date: Tue, 13 Jul 2021 18:42:36 -0400 Subject: [PATCH 24/48] feat(black-jack): update readme for example --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index d2512752a..3305b41c6 100644 --- a/README.md +++ b/README.md @@ -73,3 +73,8 @@ * from the browser, navigate to the _forked_ project from **your** github account. * click the `Pull Requests` tab. * select `New Pull Request` + + + + +## Adding a line to the readMe for git hub example From 56a1db9d36e941089afb4f50aaf82311f2c1b574 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 20:19:03 -0400 Subject: [PATCH 25/48] feat/black-jack update --- .../casino/games/blackjack/BlackJack.java | 71 +++---------- .../casino/games/blackjack/BlackJackGame.java | 100 ++++++++++++++++++ 2 files changed, 117 insertions(+), 54 deletions(-) create mode 100644 src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java index 4e08ad9dc..e09810a4c 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java @@ -7,14 +7,15 @@ import java.util.*; -public class BlackJack implements GameInterface, PlayerInterface { +public class BlackJack { List playersHand; + List playersHandOnSplit; List dealersHand; Deque deckOfCards; - Double betAmount; // Equal to user input public BlackJack () { this.playersHand = new ArrayList<>(); + this.playersHandOnSplit = new ArrayList<>(); this.dealersHand = new ArrayList<>(); this.deckOfCards = new ArrayDeque<>(generateNewDeck()); } @@ -30,6 +31,12 @@ public List givePlayerCard () { return this.playersHand; } + public List givePlayerCardOnSplit () { + Integer valueOfCard = deckOfCards.pop(); + this.playersHandOnSplit.add(valueOfCard); + return this.playersHandOnSplit; + } + public List giveDealerCard () { Integer valueOfCard = deckOfCards.pop(); this.dealersHand.add(valueOfCard); @@ -54,23 +61,19 @@ public Integer dealersCurrentValue () { return sum; } - public void playerBroke21 () { + public boolean playerBreaks21 () { if (playersCurrentValue() > 21) { - subtractBetFromBalance(betAmount); + return true; + } else { + return false; } } - public void playerBlackJack () { + public boolean playerHitsBlackJack () { if (playersCurrentValue() == 21) { - calculateWinnings(3.0, betAmount); - } - } - - public void dealerConditions () { - if (dealersCurrentValue() > 21) { - calculateWinnings(2.0, betAmount); //Players winnings, not dealers (Player won) - } else if (dealersCurrentValue() <= 21 && dealersCurrentValue() > playersCurrentValue()) { - subtractBetFromBalance(betAmount); + return true; + } else { + return false; } } @@ -89,44 +92,4 @@ public List getDealersHand() { public void setDealersHand(List dealersHand) { this.dealersHand = dealersHand; } - - @Override - public void add(PlayerInterface player) { - - } - - @Override - public void remove(PlayerInterface player) { - - } - - @Override - public void run() { - - } - - @Override - public Double calculateWinnings(Double multiplier, Double betAmount) { - return null; - } - - @Override - public void subtractBetFromBalance(Double betAmount) { - - } - - @Override - public void addMoneyToBalance(PlayerInterface Player, Double winnings) { - - } - - @Override - public CasinoAccount getArcadeAccount() { - return null; - } - - @Override - public SomeReturnType play() { - return null; - } } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java new file mode 100644 index 000000000..d05746c24 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java @@ -0,0 +1,100 @@ +package com.github.zipcodewilmington.casino.games.blackjack; + +import com.github.zipcodewilmington.casino.CasinoAccount; +import com.github.zipcodewilmington.casino.GameInterface; +import com.github.zipcodewilmington.casino.Player; +import com.github.zipcodewilmington.casino.PlayerInterface; +import com.github.zipcodewilmington.utils.IOConsole; + +import java.util.Scanner; + +public class BlackJackGame implements GameInterface, PlayerInterface { + private BlackJack game; + private Boolean isRunning = false; + private PlayerInterface player; + private Double userBet; + IOConsole input = new IOConsole(); + + @Override + public void add(PlayerInterface player) { + + } + + @Override + public void remove(PlayerInterface player) { + + } + + @Override + public void run() { + while(isRunning) { + // include betting range + + BlackJack bj = new BlackJack(); + Integer userInput = input.getIntegerInput("1. Start A Hand" + "\n" + "2. Quit" + "\n"); + + switch (userInput) { + case 1: // include betting forum in case 1 + startGame(); + break; + case 2: + isRunning = true; + } + } + } + + public void startGame () { + BlackJack bj = new BlackJack(); + bj.givePlayerCard(); + System.out.println("Your starting card : " + bj.playersCurrentValue()); + bj.givePlayerCard(); + System.out.println("Your second next card : " + bj.playersCurrentValue()); + boolean isWinner = false; + Integer userChoice = input.getIntegerInput("1. Hit" + "\n" + "2. Stay"); + while (isWinner) { + switch (userChoice) { + case 1: + bj.givePlayerCard(); + bj.playersCurrentValue(); + if(bj.playerBreaks21()) { + System.out.println("Sorry bud, you got " + bj.playersCurrentValue() + + "better luck next time"); + subtractBetFromBalance(userBet); + isWinner = true; + } else if (bj.playerHitsBlackJack()) { + System.out.println("BLACK JACK!!"); + calculateWinnings(3.0, userBet); + isWinner = true; + } + break; + case 2: + + } + } + } + + @Override + public Double calculateWinnings(Double multiplier, Double betAmount) { + return multiplier * betAmount; + } + + @Override + public void subtractBetFromBalance(Double betAmount) { + + } + + @Override + public void addMoneyToBalance(PlayerInterface Player, Double winnings) { + + } + + @Override + public CasinoAccount getArcadeAccount() { + return null; + } + + @Override + public SomeReturnType play() { + return null; + } +} From dbda6904574bc29af01a9b35978ef212a3acd518 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 20:43:25 -0400 Subject: [PATCH 26/48] pulling --- .../zipcodewilmington/casino/games/blackjack/BlackJackGame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java index d05746c24..27574d10a 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java @@ -68,7 +68,7 @@ public void startGame () { } break; case 2: - + } } } From 412c509f82d74b3b4e090a4e041cc3b888752b18 Mon Sep 17 00:00:00 2001 From: ZachSinger <32113115+ZachSinger@users.noreply.github.com> Date: Tue, 13 Jul 2021 20:48:40 -0400 Subject: [PATCH 27/48] CasinoAccount and CasinoAccountManager.java (#19) Co-authored-by: Zach --- .../casino/CasinoAccount.java | 29 +++++++++++++++++++ .../casino/CasinoAccountManager.java | 23 ++++++++++----- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java index 654c749b4..4a4295907 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java @@ -1,9 +1,38 @@ package com.github.zipcodewilmington.casino; +import com.github.zipcodewilmington.Casino; + +import java.util.ArrayList; +import java.util.List; + /** * Created by leon on 7/21/2020. * `ArcadeAccount` is registered for each user of the `Arcade`. * The `ArcadeAccount` is used to log into the system to select a `Game` to play. */ public class CasinoAccount { + private String password; + private String accountName; + + + public CasinoAccount(String accountName, String accountPassword){ + this.accountName = accountName; + this.password = accountPassword; + } + + + + /* + public void setPassword(String password){ + if(this.validPass()){ + if(this.confirmPass()){ + this.password = password; + } else { + + } + } + } + + */ + } diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java index 2d09ec2a0..e1b55bd40 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java @@ -1,11 +1,15 @@ package com.github.zipcodewilmington.casino; +import java.util.ArrayList; +import java.util.List; + /** * Created by leon on 7/21/2020. * `ArcadeAccountManager` stores, manages, and retrieves `ArcadeAccount` objects * it is advised that every instruction in this class is logged */ public class CasinoAccountManager { + private List accountList = new ArrayList(); /** * @param accountName name of account to be returned * @param accountPassword password of account to be returned @@ -26,10 +30,12 @@ public CasinoAccount getAccount(String accountName, String accountPassword) { * @return new instance of `ArcadeAccount` with specified `accountName` and `accountPassword` */ public CasinoAccount createAccount(String accountName, String accountPassword) { - String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName(); - String currentClassName = getClass().getName(); - String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented"; - throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName)); + CasinoAccount myAccount = new CasinoAccount(accountName, accountPassword); + return myAccount; + //String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName(); + //String currentClassName = getClass().getName(); + //String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented"; + //throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName)); } /** @@ -38,9 +44,10 @@ public CasinoAccount createAccount(String accountName, String accountPassword) { * @param casinoAccount the arcadeAccount to be added to `this.getArcadeAccountList()` */ public void registerAccount(CasinoAccount casinoAccount) { - String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName(); - String currentClassName = getClass().getName(); - String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented"; - throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName)); + this.accountList.add(casinoAccount); + //String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName(); + //String currentClassName = getClass().getName(); + //String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented"; + //throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName)); } } From 36b2994354f8ad08142e2caad89d2cddcc047103 Mon Sep 17 00:00:00 2001 From: Dipinti Date: Tue, 13 Jul 2021 21:14:05 -0400 Subject: [PATCH 28/48] plinkogame and plinkotest done --- .../casino/games/plinko/PlinkoGame.java | 100 ++++++++++++++++++ .../github/zipcodewilmington/PlinkoTest.java | 44 ++++++++ 2 files changed, 144 insertions(+) create mode 100644 src/main/java/com/github/zipcodewilmington/casino/games/plinko/PlinkoGame.java create mode 100644 src/test/java/com/github/zipcodewilmington/PlinkoTest.java diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/plinko/PlinkoGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/plinko/PlinkoGame.java new file mode 100644 index 000000000..c9fc6140a --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/plinko/PlinkoGame.java @@ -0,0 +1,100 @@ +package com.github.zipcodewilmington.casino.games.plinko; + +import com.github.zipcodewilmington.casino.CasinoAccount; +import com.github.zipcodewilmington.casino.GameInterface; +import com.github.zipcodewilmington.casino.PlayerInterface; + +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +public class PlinkoGame implements GameInterface,PlayerInterface { + private Map moneyGenerator=new HashMap(); + public int initialPosition; + private double betAmount; + public int randomNumber; + + public PlinkoGame(int initialPosition){ + this.initialPosition=initialPosition; + } + + public String playPlinko(int initialPosition){ + if(initialPosition<10 && initialPosition>0){ + int max=9; + int min=1; + Random rand = new Random(); + int randomNumber=rand.nextInt(max - min + 1) + min; + return String.valueOf(randomNumber); + } + else + return "Invalid Entry"; + } + + @Override + public void add(PlayerInterface player) { + + } + + @Override + public void remove(PlayerInterface player) { + + } + + @Override + public void run() { + if (initialPosition < 10 && initialPosition > 0) { + int max = 9; + int min = 1; + Random rand = new Random(); + randomNumber = rand.nextInt(max - min + 1) + min; + System.out.println("Now your position is: " + randomNumber); + } + else + { + System.out.println("Invalid Entry"); + } + } + + @Override + public Double calculateWinnings(Double multiplier, Double betAmount) { + moneyGenerator.put(1,200.00); + moneyGenerator.put(2,0.00); + moneyGenerator.put(3,3000.00); + moneyGenerator.put(4,30.50); + moneyGenerator.put(5,0.00); + moneyGenerator.put(6,0.00); + moneyGenerator.put(7,1.00); + moneyGenerator.put(8,750.50); + moneyGenerator.put(9,0.00); + Double moneyWon=0.0; + for (Integer pos:moneyGenerator.keySet()) + { + if(pos.equals(randomNumber)){ + moneyWon=moneyGenerator.get(pos); + } + } + return moneyWon; + } + + + @Override + public void subtractBetFromBalance(Double betAmount) { + + } + + @Override + public void addMoneyToBalance(PlayerInterface Player, Double winnings) { + + } + + @Override + public CasinoAccount getArcadeAccount() { + return null; + } + + @Override + public SomeReturnType play() { + return null; + } +} + diff --git a/src/test/java/com/github/zipcodewilmington/PlinkoTest.java b/src/test/java/com/github/zipcodewilmington/PlinkoTest.java new file mode 100644 index 000000000..8596899de --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/PlinkoTest.java @@ -0,0 +1,44 @@ +package com.github.zipcodewilmington; + +import com.github.zipcodewilmington.casino.games.plinko.PlinkoGame; +import org.junit.Assert; +import org.junit.Test; + +public class PlinkoTest { + + @Test + public void testCalculateWinnings() { + //given + Double expectedValue=0.0; + PlinkoGame plinkoGame=new PlinkoGame(7); + plinkoGame.run(); + //when + Double actualValue=plinkoGame.calculateWinnings(2.00,200.00); + //then + System.out.println(actualValue); + Assert.assertEquals(expectedValue,actualValue); + } + + @Test + public void testConstructor(){ + //given + int expectedValue=8; + //when + PlinkoGame plinkoGame=new PlinkoGame(8); + int actualValue=plinkoGame.initialPosition; + //then + Assert.assertEquals(expectedValue,actualValue); + } + + @Test + public void testPlayPlinko(){ + //given + String expectedValue="Invalid Entry"; + //when + PlinkoGame plinkoGame=new PlinkoGame(10); + String actualValue=plinkoGame.playPlinko(10); + //then + Assert.assertFalse(expectedValue, Boolean.parseBoolean(actualValue)); + } +} + From 215c282dea0773bd7aa0b3a7ddaf24f06beed64c Mon Sep 17 00:00:00 2001 From: ZachSinger <32113115+ZachSinger@users.noreply.github.com> Date: Tue, 13 Jul 2021 21:14:18 -0400 Subject: [PATCH 29/48] Feature/casino account (#20) * CasinoAccount and CasinoAccountManager.java * updated CasinoAccount, CasinoAccountManager and Casino java files Co-authored-by: Zach --- .../com/github/zipcodewilmington/Casino.java | 2 +- .../zipcodewilmington/casino/CasinoAccount.java | 17 ++++++----------- .../casino/CasinoAccountManager.java | 10 ++++++++++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/Casino.java b/src/main/java/com/github/zipcodewilmington/Casino.java index 5eae9ac0c..72e424327 100644 --- a/src/main/java/com/github/zipcodewilmington/Casino.java +++ b/src/main/java/com/github/zipcodewilmington/Casino.java @@ -42,7 +42,7 @@ public void run() { } else { // TODO - implement better exception handling String errorMessage = "No account found with name of [ %s ] and password of [ %s ]"; - throw new RuntimeException(String.format(errorMessage, accountPassword, accountName)); + //throw new RuntimeException(String.format(errorMessage, accountPassword, accountName)); } } else if ("create-account".equals(arcadeDashBoardInput)) { console.println("Welcome to the account-creation screen."); diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java index 4a4295907..580cf89b1 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java @@ -21,18 +21,13 @@ public CasinoAccount(String accountName, String accountPassword){ } - - /* - public void setPassword(String password){ - if(this.validPass()){ - if(this.confirmPass()){ - this.password = password; - } else { - - } - } +feature/CasinoAccount + public String getPassword() { + return password; } - */ + public String getAccountName() { + return accountName; + } } diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java index e1b55bd40..459c69af5 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java @@ -16,6 +16,16 @@ public class CasinoAccountManager { * @return `ArcadeAccount` with specified `accountName` and `accountPassword` */ public CasinoAccount getAccount(String accountName, String accountPassword) { + for(int i = 0; i < accountList.size(); i++){ + CasinoAccount currentAccount = accountList.get(i); + if(currentAccount.getAccountName() == accountName && + currentAccount.getPassword() == accountPassword){ + return currentAccount; + } else { + System.out.println("Account Name or Password does not match. Are you really you?"); + return null; + } + } String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName(); String currentClassName = getClass().getName(); String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented"; From a2018af0a715baab598acf924b96708a3ff302f5 Mon Sep 17 00:00:00 2001 From: ZachSinger <32113115+ZachSinger@users.noreply.github.com> Date: Tue, 13 Jul 2021 21:24:07 -0400 Subject: [PATCH 30/48] Feature/casino account (#21) * CasinoAccount and CasinoAccountManager.java * updated CasinoAccount, CasinoAccountManager and Casino java files Co-authored-by: Zach From 71abb548dac44b6e74f87a8ec3c29ffba6aac537 Mon Sep 17 00:00:00 2001 From: ZachSinger <32113115+ZachSinger@users.noreply.github.com> Date: Tue, 13 Jul 2021 21:27:02 -0400 Subject: [PATCH 31/48] pulling (#22) Co-authored-by: Nick --- .../zipcodewilmington/casino/games/blackjack/BlackJackGame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java index d05746c24..27574d10a 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java @@ -68,7 +68,7 @@ public void startGame () { } break; case 2: - + } } } From 5c5161361875087fd6dcae4cb98282d05955ff73 Mon Sep 17 00:00:00 2001 From: Dipinti Date: Tue, 13 Jul 2021 21:29:59 -0400 Subject: [PATCH 32/48] plinko.java is ready --- .../com/github/zipcodewilmington/Casino.java | 2 +- .../zipcodewilmington/casino/CasinoAccount.java | 17 ++++++----------- .../casino/CasinoAccountManager.java | 10 ++++++++++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/Casino.java b/src/main/java/com/github/zipcodewilmington/Casino.java index 5eae9ac0c..72e424327 100644 --- a/src/main/java/com/github/zipcodewilmington/Casino.java +++ b/src/main/java/com/github/zipcodewilmington/Casino.java @@ -42,7 +42,7 @@ public void run() { } else { // TODO - implement better exception handling String errorMessage = "No account found with name of [ %s ] and password of [ %s ]"; - throw new RuntimeException(String.format(errorMessage, accountPassword, accountName)); + //throw new RuntimeException(String.format(errorMessage, accountPassword, accountName)); } } else if ("create-account".equals(arcadeDashBoardInput)) { console.println("Welcome to the account-creation screen."); diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java index 4a4295907..580cf89b1 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java @@ -21,18 +21,13 @@ public CasinoAccount(String accountName, String accountPassword){ } - - /* - public void setPassword(String password){ - if(this.validPass()){ - if(this.confirmPass()){ - this.password = password; - } else { - - } - } +feature/CasinoAccount + public String getPassword() { + return password; } - */ + public String getAccountName() { + return accountName; + } } diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java index e1b55bd40..459c69af5 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java @@ -16,6 +16,16 @@ public class CasinoAccountManager { * @return `ArcadeAccount` with specified `accountName` and `accountPassword` */ public CasinoAccount getAccount(String accountName, String accountPassword) { + for(int i = 0; i < accountList.size(); i++){ + CasinoAccount currentAccount = accountList.get(i); + if(currentAccount.getAccountName() == accountName && + currentAccount.getPassword() == accountPassword){ + return currentAccount; + } else { + System.out.println("Account Name or Password does not match. Are you really you?"); + return null; + } + } String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName(); String currentClassName = getClass().getName(); String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented"; From 278a0ca87fa271bda212aa66449fd5fd62bf0f7b Mon Sep 17 00:00:00 2001 From: ZachSinger <32113115+ZachSinger@users.noreply.github.com> Date: Tue, 13 Jul 2021 21:36:11 -0400 Subject: [PATCH 33/48] Feature/casino account (#23) * CasinoAccount and CasinoAccountManager.java * updated CasinoAccount, CasinoAccountManager and Casino java files Co-authored-by: Zach From 248f47f2b724f57c0db4a61ff1106907b11a1623 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 21:44:43 -0400 Subject: [PATCH 34/48] (feat:black-jack) game logic completed, need refinment and bet input --- .../casino/games/blackjack/BlackJack.java | 24 +++++++++++++++++++ .../casino/games/blackjack/BlackJackGame.java | 15 ++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java index e09810a4c..5f16b25b1 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java @@ -12,6 +12,8 @@ public class BlackJack { List playersHandOnSplit; List dealersHand; Deque deckOfCards; + BlackJackGame theGame = new BlackJackGame(); + boolean gameEnd = false; public BlackJack () { this.playersHand = new ArrayList<>(); @@ -61,6 +63,28 @@ public Integer dealersCurrentValue () { return sum; } + public void dealersGame () { + while(!gameEnd) { + System.out.println("The dealer has : " + dealersCurrentValue()); + if (dealersCurrentValue() > 21) { + System.out.println("You win!"); + theGame.calculateWinnings(2.0, theGame.userBet); + gameEnd = true; + } else if (dealersCurrentValue() == 21) { + System.out.println("The dealer has won!"); + theGame.subtractBetFromBalance(theGame.userBet); + gameEnd = true; + } else if (dealersCurrentValue() > playersCurrentValue()) { + System.out.println("The dealer has won!"); + theGame.subtractBetFromBalance(theGame.userBet); + gameEnd = true; + } else { + giveDealerCard(); + System.out.println("The dealer has : " + dealersCurrentValue()); + } + } + } + public boolean playerBreaks21 () { if (playersCurrentValue() > 21) { return true; diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java index 27574d10a..66c53e156 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java @@ -12,8 +12,9 @@ public class BlackJackGame implements GameInterface, PlayerInterface { private BlackJack game; private Boolean isRunning = false; private PlayerInterface player; - private Double userBet; + Double userBet; IOConsole input = new IOConsole(); + boolean isWinner = false; @Override public void add(PlayerInterface player) { @@ -49,9 +50,8 @@ public void startGame () { System.out.println("Your starting card : " + bj.playersCurrentValue()); bj.givePlayerCard(); System.out.println("Your second next card : " + bj.playersCurrentValue()); - boolean isWinner = false; Integer userChoice = input.getIntegerInput("1. Hit" + "\n" + "2. Stay"); - while (isWinner) { + while (!isWinner) { switch (userChoice) { case 1: bj.givePlayerCard(); @@ -68,9 +68,14 @@ public void startGame () { } break; case 2: - - } + bj.giveDealerCard(); + System.out.println("The dealers first card : " + bj.dealersCurrentValue()); + bj.giveDealerCard(); + System.out.println("The dealer has : " + bj.dealersCurrentValue()); + bj.dealersGame(); + break; } + } } @Override From eb43adc5aea6f2808ae5192219035b42dfc3e7ff Mon Sep 17 00:00:00 2001 From: tnguyen1912 Date: Tue, 13 Jul 2021 22:17:36 -0400 Subject: [PATCH 35/48] Feature/slots (#24) * new feature incoming * 950 attempt Co-authored-by: Nathan Co-authored-by: ZachSinger <32113115+ZachSinger@users.noreply.github.com> --- .../casino/CasinoAccount.java | 1 + .../casino/GameInterface.java | 6 +- .../casino/games/Beetle/BeetleGame.java | 15 +++++ .../casino/games/blackjack/BlackJack.java | 52 +++++++++++++++ .../casino/games/slots/Slots.java | 64 ++++++++++++++----- .../casino/games/slots/SlotsGame.java | 14 ++-- .../github/zipcodewilmington/SlotsTest.java | 57 +++++++++++++++++ 7 files changed, 184 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java index 580cf89b1..cd2f4bb82 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java @@ -21,6 +21,7 @@ public CasinoAccount(String accountName, String accountPassword){ } + feature/CasinoAccount public String getPassword() { return password; diff --git a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java index 1e825b192..01ddd0568 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java +++ b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java @@ -26,16 +26,16 @@ public interface GameInterface extends Runnable { * Calculate player's winning payout amount of bet x multiplier * @return (double) amount of money winnings */ - Double calculateWinnings(Double multiplier, Double betAmount); + Integer calculateWinnings(Integer multiplier, Integer betAmount); /** * Subtract the bet amount from player's balance */ - void subtractBetFromBalance(Double betAmount); + void subtractBetFromBalance(Integer betAmount); /** * Add winnings amount to player's balance */ - void addMoneyToBalance(PlayerInterface Player, Double winnings); + void addMoneyToBalance(PlayerInterface Player, Integer winnings); } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java index a00b9b9c1..cbc91fb07 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java @@ -31,6 +31,21 @@ public void run(){ } } + @Override + public Integer calculateWinnings(Integer multiplier, Integer betAmount) { + return null; + } + + @Override + public void subtractBetFromBalance(Integer betAmount) { + + } + + @Override + public void addMoneyToBalance(PlayerInterface Player, Integer winnings) { + + } + public String test(){ return "NATHAN WAS HERE"; } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java index e09810a4c..24374b05e 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java @@ -13,6 +13,8 @@ public class BlackJack { List dealersHand; Deque deckOfCards; + Integer betAmount; // Equal to user input + public BlackJack () { this.playersHand = new ArrayList<>(); this.playersHandOnSplit = new ArrayList<>(); @@ -71,6 +73,15 @@ public boolean playerBreaks21 () { public boolean playerHitsBlackJack () { if (playersCurrentValue() == 21) { + calculateWinnings(3, betAmount); + } + } + + public void dealerConditions () { + if (dealersCurrentValue() > 21) { + calculateWinnings(2, betAmount); //Players winnings, not dealers (Player won) + } else if (dealersCurrentValue() <= 21 && dealersCurrentValue() > playersCurrentValue()) { + subtractBetFromBalance(betAmount); return true; } else { return false; @@ -92,4 +103,45 @@ public List getDealersHand() { public void setDealersHand(List dealersHand) { this.dealersHand = dealersHand; } + + @Override + public void add(PlayerInterface player) { + + } + + @Override + public void remove(PlayerInterface player) { + + } + + @Override + public void run() { + + } + + @Override + public Integer calculateWinnings(Integer multiplier, Integer betAmount) { + return null; + } + + @Override + public void subtractBetFromBalance(Integer betAmount) { + + } + + @Override + public void addMoneyToBalance(PlayerInterface Player, Integer winnings) { + + } + + @Override + public CasinoAccount getArcadeAccount() { + return null; + } + + @Override + public SomeReturnType play() { + return null; + } + } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java index 970289ee9..ebbfe37ad 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java @@ -1,21 +1,32 @@ package com.github.zipcodewilmington.casino.games.slots; - -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; + public class Slots { private static final String[] slotItems = {"Peach", "Cherry", "Diamond", "Plum", "Seven", "Nine"}; private String[][] slots = new String[3][3]; - private List slotsList = new ArrayList<>(); + private HashMap winningLines = new HashMap<>(); + + public Slots(String[][] slots) { + //this.winningLines = new HashMap<>(); + this.slots = slots; + initializeWinningLines(); + } public Slots(){ + //this.winningLines = new HashMap<>(); this.slots = new String[][] { {"Peach", "Cherry", "Diamond"}, {"Diamond", "Plum", "Nine"}, {"Seven", "Peach", "Diamond"}}; + initializeWinningLines(); + } + + private void initializeWinningLines(){ + for (int i = 1; i < 9; i++) { + winningLines.put(i, "LOSE"); + } } public String[][] getSlots() { @@ -26,6 +37,10 @@ public void setSlots(String[][] slots) { this.slots = slots; } + public HashMap getWinningLines() { + return winningLines; + } + public void spinSlots(){ String[][] newSlot = new String[3][3]; for (int a = 0; a < 3; a++) { @@ -43,18 +58,35 @@ public static String ramdomSlotItem(){ return result; } - public static void findWinnings(){ - HashMap winningLines = new HashMap<>(); - winningLines.put(1,"Lose"); - winningLines.put(2,"Lose"); - winningLines.put(3,"Lose"); - winningLines.put(4,"Lose"); - winningLines.put(5,"Lose"); - winningLines.put(6,"Lose"); - winningLines.put(7,"Lose"); - - + public void setWinningLines(){ + String[][] currentSlots = this.getSlots(); + HashMap newWinningLines = new HashMap<>(); + for (int i = 0; i < 3; i++) { + //setting horizontally + if(currentSlots[i][0].equals(currentSlots[i][1]) && currentSlots[i][0].equals(currentSlots[i][2])){ + newWinningLines.put((i+1),"WIN"); + } + //setting vertically + if(currentSlots[0][i].equals(currentSlots[1][i]) && currentSlots[2][i].equals(currentSlots[i][2])){ + newWinningLines.put((i+4),"WIN"); + } + } + //setting diagonally + if(currentSlots[0][0].equals(currentSlots[1][1]) && currentSlots[0][0].equals(currentSlots[2][2])){ + newWinningLines.put(7,"WIN"); + } + if(currentSlots[2][2].equals(currentSlots[1][1]) && currentSlots[2][2].equals(currentSlots[0][0])){ + newWinningLines.put(8,"WIN"); + } + this.winningLines = newWinningLines; + } + public String[] compareBetVsWinningLines(Integer[] bets){ + String[] result = new String[bets.length]; + for (int i = 0; i < bets.length; i++) { + result[i] = winningLines.get(bets[i]); + } + return result; } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java index 81a36ff91..102c0eb63 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java @@ -7,9 +7,6 @@ * Created by Nathan on 7/12/21 */ public class SlotsGame implements GameInterface { - private static String[] slotItems = {"Peach", "Cherry", "Diamond", "Plum", "Seven", "Nine"}; - private String[][] slots = new String[3][3]; - @Override @@ -24,21 +21,26 @@ public void remove(PlayerInterface player) { @Override public void run() { + Slots slotMachine = new Slots(); + //Integer[] bets = takeBet(); + slotMachine.spinSlots(); + //slotMachine.compareBetVsWinningLines(); + } @Override - public Double calculateWinnings(Double multiplier, Double betAmount) { + public Integer calculateWinnings(Integer multiplier, Integer betAmount) { return null; } @Override - public void subtractBetFromBalance(Double betAmount) { + public void subtractBetFromBalance(Integer betAmount) { } @Override - public void addMoneyToBalance(PlayerInterface Player, Double winnings) { + public void addMoneyToBalance(PlayerInterface Player, Integer winnings) { } } diff --git a/src/test/java/com/github/zipcodewilmington/SlotsTest.java b/src/test/java/com/github/zipcodewilmington/SlotsTest.java index 97f2fa7c5..e21f3cf68 100644 --- a/src/test/java/com/github/zipcodewilmington/SlotsTest.java +++ b/src/test/java/com/github/zipcodewilmington/SlotsTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; +import java.util.HashMap; + public class SlotsTest { @Test @@ -73,4 +75,59 @@ public void spinSlotsTest(){ //then Assert.assertFalse(given.equals(retrieved)); } + + @Test + public void initializeWinningLinesTest(){ + //given + Slots slot = new Slots(); + String[] expected = {"LOSE","LOSE","LOSE","LOSE","LOSE","LOSE","LOSE","LOSE",}; + HashMap initialWinningLines = slot.getWinningLines(); + String[] returned = new String[8]; + for (int i = 0; i < initialWinningLines.size(); i++) { + returned[i] = (String) initialWinningLines.get(i + 1); + } + //then + Assert.assertEquals(expected, returned); + + } + + @Test + public void setWinningLinesTest(){ + //given + String[][] given = { + {"Peach", "Peach", "Peach"}, + {"Peach", "Peach", "Peach"}, + {"Peach", "Peach", "Peach"}}; + Slots slot = new Slots(given); + String[] expected = {"WIN","WIN","WIN","WIN","WIN","WIN","WIN","WIN"}; + //when + slot.setWinningLines(); + HashMap winningLines = slot.getWinningLines(); + String[] returned = new String[8]; + for (int i = 0; i < winningLines.size(); i++) { + returned[i] = (String) winningLines.get(i + 1); + } + //then + Assert.assertEquals(expected,returned); + + } + + @Test + public void compareBetVsWinningLinesTest(){ + //given + String[][] given = { + {"Peach", "Peach", "Peach"}, + {"Peach", "Peach", "Peach"}, + {"Peach", "Peach", "Peach"}}; + Slots slot = new Slots(given); + slot.setWinningLines(); + String[] expected = {"WIN","WIN","WIN","WIN","WIN","WIN","WIN","WIN"}; + Integer [] bets = {1,2,3,4,5,6,7,8}; + //when + String[] returned = slot.compareBetVsWinningLines(bets); + //then + Assert.assertEquals(expected, returned); + } + + } From ffc4938af97e56215bc5edf32caf203ef76db278 Mon Sep 17 00:00:00 2001 From: Zach Date: Tue, 13 Jul 2021 22:22:02 -0400 Subject: [PATCH 36/48] CasinoAccountManager and Casino thru to game selection. Account logins successful --- .../github/zipcodewilmington/casino/CasinoAccount.java | 2 +- .../zipcodewilmington/casino/CasinoAccountManager.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java index 580cf89b1..70b97fef0 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java @@ -21,7 +21,7 @@ public CasinoAccount(String accountName, String accountPassword){ } -feature/CasinoAccount + public String getPassword() { return password; } diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java index 459c69af5..0e8b08ef8 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java @@ -18,9 +18,11 @@ public class CasinoAccountManager { public CasinoAccount getAccount(String accountName, String accountPassword) { for(int i = 0; i < accountList.size(); i++){ CasinoAccount currentAccount = accountList.get(i); - if(currentAccount.getAccountName() == accountName && - currentAccount.getPassword() == accountPassword){ - return currentAccount; + String pass = currentAccount.getPassword(); + String name = currentAccount.getAccountName(); + if(name.equals(accountName)) + if(pass.equals(accountPassword)){ + return currentAccount; } else { System.out.println("Account Name or Password does not match. Are you really you?"); return null; From 9308a8f4300fa43281b1dcfd3eb7af5b62851b32 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 22:26:03 -0400 Subject: [PATCH 37/48] (feat:black-jack) game logic built, continuing on formatting --- .../casino/games/blackjack/BlackJackGame.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java index 66c53e156..749124ea3 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java @@ -6,10 +6,8 @@ import com.github.zipcodewilmington.casino.PlayerInterface; import com.github.zipcodewilmington.utils.IOConsole; -import java.util.Scanner; public class BlackJackGame implements GameInterface, PlayerInterface { - private BlackJack game; private Boolean isRunning = false; private PlayerInterface player; Double userBet; @@ -30,12 +28,13 @@ public void remove(PlayerInterface player) { public void run() { while(isRunning) { // include betting range - BlackJack bj = new BlackJack(); Integer userInput = input.getIntegerInput("1. Start A Hand" + "\n" + "2. Quit" + "\n"); switch (userInput) { - case 1: // include betting forum in case 1 + case 1: + this.userBet = Double.valueOf(input.getIntegerInput("How much would you like to bet?")); + // include betting forum in case 1 startGame(); break; case 2: @@ -48,8 +47,8 @@ public void startGame () { BlackJack bj = new BlackJack(); bj.givePlayerCard(); System.out.println("Your starting card : " + bj.playersCurrentValue()); - bj.givePlayerCard(); - System.out.println("Your second next card : " + bj.playersCurrentValue()); + System.out.println("Your second next card : " + bj.givePlayerCard()); + System.out.println("Hand value : " + bj.playersCurrentValue()); Integer userChoice = input.getIntegerInput("1. Hit" + "\n" + "2. Stay"); while (!isWinner) { switch (userChoice) { From 321ff082353a34dec7b086c6944acf622f8bb099 Mon Sep 17 00:00:00 2001 From: ZachSinger <32113115+ZachSinger@users.noreply.github.com> Date: Tue, 13 Jul 2021 22:28:29 -0400 Subject: [PATCH 38/48] Feature/casino account (#27) * CasinoAccount and CasinoAccountManager.java * updated CasinoAccount, CasinoAccountManager and Casino java files Co-authored-by: Zach --- .../com/github/zipcodewilmington/casino/CasinoAccount.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java index c5f41dcb6..cd5b53aef 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java @@ -21,11 +21,6 @@ public CasinoAccount(String accountName, String accountPassword){ } - -<<<<<<< HEAD -======= -feature/CasinoAccount ->>>>>>> eb43adc5aea6f2808ae5192219035b42dfc3e7ff public String getPassword() { return password; } From f60d2829ff17534e5bbb0c9c52f9c55e798bbe14 Mon Sep 17 00:00:00 2001 From: NicholasWolak <85853075+NicholasWolak@users.noreply.github.com> Date: Tue, 13 Jul 2021 22:31:08 -0400 Subject: [PATCH 39/48] Feat/black jack (#26) * pulling * (feat:black-jack) game logic completed, need refinment and bet input * (feat:black-jack) game logic built, continuing on formatting Co-authored-by: Nick --- .../casino/games/blackjack/BlackJack.java | 24 +++++++++++++++++ .../casino/games/blackjack/BlackJackGame.java | 27 ++++++++++++------- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java index 24374b05e..61bce33e2 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java @@ -12,6 +12,8 @@ public class BlackJack { List playersHandOnSplit; List dealersHand; Deque deckOfCards; + BlackJackGame theGame = new BlackJackGame(); + boolean gameEnd = false; Integer betAmount; // Equal to user input @@ -63,6 +65,28 @@ public Integer dealersCurrentValue () { return sum; } + public void dealersGame () { + while(!gameEnd) { + System.out.println("The dealer has : " + dealersCurrentValue()); + if (dealersCurrentValue() > 21) { + System.out.println("You win!"); + theGame.calculateWinnings(2.0, theGame.userBet); + gameEnd = true; + } else if (dealersCurrentValue() == 21) { + System.out.println("The dealer has won!"); + theGame.subtractBetFromBalance(theGame.userBet); + gameEnd = true; + } else if (dealersCurrentValue() > playersCurrentValue()) { + System.out.println("The dealer has won!"); + theGame.subtractBetFromBalance(theGame.userBet); + gameEnd = true; + } else { + giveDealerCard(); + System.out.println("The dealer has : " + dealersCurrentValue()); + } + } + } + public boolean playerBreaks21 () { if (playersCurrentValue() > 21) { return true; diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java index 27574d10a..dde701b86 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java @@ -6,14 +6,13 @@ import com.github.zipcodewilmington.casino.PlayerInterface; import com.github.zipcodewilmington.utils.IOConsole; -import java.util.Scanner; public class BlackJackGame implements GameInterface, PlayerInterface { - private BlackJack game; private Boolean isRunning = false; private PlayerInterface player; - private Double userBet; + Double userBet; IOConsole input = new IOConsole(); + boolean isWinner = false; @Override public void add(PlayerInterface player) { @@ -29,12 +28,13 @@ public void remove(PlayerInterface player) { public void run() { while(isRunning) { // include betting range - BlackJack bj = new BlackJack(); Integer userInput = input.getIntegerInput("1. Start A Hand" + "\n" + "2. Quit" + "\n"); switch (userInput) { - case 1: // include betting forum in case 1 + case 1: + this.userBet = Double.valueOf(input.getIntegerInput("How much would you like to bet?")); + // include betting forum in case 1 startGame(); break; case 2: @@ -47,11 +47,10 @@ public void startGame () { BlackJack bj = new BlackJack(); bj.givePlayerCard(); System.out.println("Your starting card : " + bj.playersCurrentValue()); - bj.givePlayerCard(); - System.out.println("Your second next card : " + bj.playersCurrentValue()); - boolean isWinner = false; + System.out.println("Your second next card : " + bj.givePlayerCard()); + System.out.println("Hand value : " + bj.playersCurrentValue()); Integer userChoice = input.getIntegerInput("1. Hit" + "\n" + "2. Stay"); - while (isWinner) { + while (!isWinner) { switch (userChoice) { case 1: bj.givePlayerCard(); @@ -69,8 +68,18 @@ public void startGame () { break; case 2: + bj.giveDealerCard(); + System.out.println("The dealers first card : " + bj.dealersCurrentValue()); + bj.giveDealerCard(); + System.out.println("The dealer has : " + bj.dealersCurrentValue()); + bj.dealersGame(); + break; + + } + } + } } @Override From d7b6482c7912d86dd1dc9cf068cef51d41c89219 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 22:46:08 -0400 Subject: [PATCH 40/48] commiting for merge --- .../casino/games/blackjack/BlackJack.java | 83 ++++--------------- .../casino/games/blackjack/BlackJackGame.java | 30 +++---- .../casino/games/plinko/PlinkoGame.java | 28 +++---- .../github/zipcodewilmington/PlinkoTest.java | 4 +- 4 files changed, 46 insertions(+), 99 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java index 61bce33e2..d401cf26d 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJack.java @@ -7,7 +7,7 @@ import java.util.*; -public class BlackJack { +public class BlackJack { List playersHand; List playersHandOnSplit; List dealersHand; @@ -17,46 +17,46 @@ public class BlackJack { Integer betAmount; // Equal to user input - public BlackJack () { + public BlackJack() { this.playersHand = new ArrayList<>(); this.playersHandOnSplit = new ArrayList<>(); this.dealersHand = new ArrayList<>(); this.deckOfCards = new ArrayDeque<>(generateNewDeck()); } - public List generateNewDeck () { + public List generateNewDeck() { Card card = new Card(); return card.getCardPool(); } - public List givePlayerCard () { + public List givePlayerCard() { Integer valueOfCard = deckOfCards.pop(); this.playersHand.add(valueOfCard); return this.playersHand; } - public List givePlayerCardOnSplit () { + public List givePlayerCardOnSplit() { Integer valueOfCard = deckOfCards.pop(); this.playersHandOnSplit.add(valueOfCard); return this.playersHandOnSplit; } - public List giveDealerCard () { + public List giveDealerCard() { Integer valueOfCard = deckOfCards.pop(); this.dealersHand.add(valueOfCard); return this.dealersHand; } - public Integer playersCurrentValue () { + public Integer playersCurrentValue() { givePlayerCard(); Integer sum = 0; for (int i = 0; i < this.playersHand.size(); i++) { - sum += this.playersHand.get(i); + sum += this.playersHand.get(i); } return sum; } - public Integer dealersCurrentValue () { + public Integer dealersCurrentValue() { giveDealerCard(); Integer sum = 0; for (int i = 0; i < this.dealersHand.size(); i++) { @@ -65,12 +65,12 @@ public Integer dealersCurrentValue () { return sum; } - public void dealersGame () { - while(!gameEnd) { - System.out.println("The dealer has : " + dealersCurrentValue()); + public void dealersGame() { + while (!gameEnd) { + System.out.println("The dealer has : " + dealersCurrentValue()); if (dealersCurrentValue() > 21) { System.out.println("You win!"); - theGame.calculateWinnings(2.0, theGame.userBet); + theGame.calculateWinnings(2, theGame.userBet); gameEnd = true; } else if (dealersCurrentValue() == 21) { System.out.println("The dealer has won!"); @@ -87,7 +87,7 @@ public void dealersGame () { } } - public boolean playerBreaks21 () { + public boolean playerBreaks21() { if (playersCurrentValue() > 21) { return true; } else { @@ -95,17 +95,9 @@ public boolean playerBreaks21 () { } } - public boolean playerHitsBlackJack () { + public boolean playerHitsBlackJack() { if (playersCurrentValue() == 21) { - calculateWinnings(3, betAmount); - } - } - - public void dealerConditions () { - if (dealersCurrentValue() > 21) { - calculateWinnings(2, betAmount); //Players winnings, not dealers (Player won) - } else if (dealersCurrentValue() <= 21 && dealersCurrentValue() > playersCurrentValue()) { - subtractBetFromBalance(betAmount); + theGame.calculateWinnings(3, betAmount); return true; } else { return false; @@ -127,45 +119,4 @@ public List getDealersHand() { public void setDealersHand(List dealersHand) { this.dealersHand = dealersHand; } - - @Override - public void add(PlayerInterface player) { - - } - - @Override - public void remove(PlayerInterface player) { - - } - - @Override - public void run() { - - } - - @Override - public Integer calculateWinnings(Integer multiplier, Integer betAmount) { - return null; - } - - @Override - public void subtractBetFromBalance(Integer betAmount) { - - } - - @Override - public void addMoneyToBalance(PlayerInterface Player, Integer winnings) { - - } - - @Override - public CasinoAccount getArcadeAccount() { - return null; - } - - @Override - public SomeReturnType play() { - return null; - } - -} +} \ No newline at end of file diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java index dde701b86..7935ee07a 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java @@ -10,7 +10,7 @@ public class BlackJackGame implements GameInterface, PlayerInterface { private Boolean isRunning = false; private PlayerInterface player; - Double userBet; + Integer userBet; IOConsole input = new IOConsole(); boolean isWinner = false; @@ -33,7 +33,7 @@ public void run() { switch (userInput) { case 1: - this.userBet = Double.valueOf(input.getIntegerInput("How much would you like to bet?")); + this.userBet = (input.getIntegerInput("How much would you like to bet?")); // include betting forum in case 1 startGame(); break; @@ -62,7 +62,7 @@ public void startGame () { isWinner = true; } else if (bj.playerHitsBlackJack()) { System.out.println("BLACK JACK!!"); - calculateWinnings(3.0, userBet); + calculateWinnings(3, userBet); isWinner = true; } break; @@ -74,36 +74,32 @@ public void startGame () { System.out.println("The dealer has : " + bj.dealersCurrentValue()); bj.dealersGame(); break; - - } - } } - } @Override - public Double calculateWinnings(Double multiplier, Double betAmount) { - return multiplier * betAmount; + public CasinoAccount getArcadeAccount() { + return null; } @Override - public void subtractBetFromBalance(Double betAmount) { - + public SomeReturnType play() { + return null; } @Override - public void addMoneyToBalance(PlayerInterface Player, Double winnings) { - + public Integer calculateWinnings(Integer multiplier, Integer betAmount) { + return null; } @Override - public CasinoAccount getArcadeAccount() { - return null; + public void subtractBetFromBalance(Integer betAmount) { + } @Override - public SomeReturnType play() { - return null; + public void addMoneyToBalance(PlayerInterface Player, Integer winnings) { + } } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/plinko/PlinkoGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/plinko/PlinkoGame.java index c9fc6140a..42cd5ae10 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/plinko/PlinkoGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/plinko/PlinkoGame.java @@ -9,7 +9,7 @@ import java.util.Random; public class PlinkoGame implements GameInterface,PlayerInterface { - private Map moneyGenerator=new HashMap(); + private Map moneyGenerator=new HashMap(); public int initialPosition; private double betAmount; public int randomNumber; @@ -56,17 +56,17 @@ public void run() { } @Override - public Double calculateWinnings(Double multiplier, Double betAmount) { - moneyGenerator.put(1,200.00); - moneyGenerator.put(2,0.00); - moneyGenerator.put(3,3000.00); - moneyGenerator.put(4,30.50); - moneyGenerator.put(5,0.00); - moneyGenerator.put(6,0.00); - moneyGenerator.put(7,1.00); - moneyGenerator.put(8,750.50); - moneyGenerator.put(9,0.00); - Double moneyWon=0.0; + public Integer calculateWinnings(Integer multiplier, Integer betAmount) { + moneyGenerator.put(1,200); + moneyGenerator.put(2,0); + moneyGenerator.put(3,3000); + moneyGenerator.put(4,30); + moneyGenerator.put(5,0); + moneyGenerator.put(6,0); + moneyGenerator.put(7,1); + moneyGenerator.put(8,750); + moneyGenerator.put(9,0); + Integer moneyWon=0; for (Integer pos:moneyGenerator.keySet()) { if(pos.equals(randomNumber)){ @@ -78,12 +78,12 @@ public Double calculateWinnings(Double multiplier, Double betAmount) { @Override - public void subtractBetFromBalance(Double betAmount) { + public void subtractBetFromBalance(Integer betAmount) { } @Override - public void addMoneyToBalance(PlayerInterface Player, Double winnings) { + public void addMoneyToBalance(PlayerInterface Player, Integer winnings) { } diff --git a/src/test/java/com/github/zipcodewilmington/PlinkoTest.java b/src/test/java/com/github/zipcodewilmington/PlinkoTest.java index 8596899de..781c43d59 100644 --- a/src/test/java/com/github/zipcodewilmington/PlinkoTest.java +++ b/src/test/java/com/github/zipcodewilmington/PlinkoTest.java @@ -9,11 +9,11 @@ public class PlinkoTest { @Test public void testCalculateWinnings() { //given - Double expectedValue=0.0; + Integer expectedValue=0; PlinkoGame plinkoGame=new PlinkoGame(7); plinkoGame.run(); //when - Double actualValue=plinkoGame.calculateWinnings(2.00,200.00); + Integer actualValue=plinkoGame.calculateWinnings(2,200); //then System.out.println(actualValue); Assert.assertEquals(expectedValue,actualValue); From a867caf8dc027e133e4544516778f033ca394442 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 13 Jul 2021 23:29:10 -0400 Subject: [PATCH 41/48] added new comment in slots --- .../com/github/zipcodewilmington/casino/games/slots/Slots.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java index ebbfe37ad..ec0b36e6b 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/Slots.java @@ -89,7 +89,7 @@ public String[] compareBetVsWinningLines(Integer[] bets){ return result; } - +//new comment } From f751781200732225c86f1b6ad53a6829624fbc86 Mon Sep 17 00:00:00 2001 From: Zach Date: Tue, 13 Jul 2021 23:35:34 -0400 Subject: [PATCH 42/48] Changed Double data type to Integer in Player class --- .../github/zipcodewilmington/casino/Player.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/Player.java b/src/main/java/com/github/zipcodewilmington/casino/Player.java index f81eef273..607512047 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/Player.java +++ b/src/main/java/com/github/zipcodewilmington/casino/Player.java @@ -3,10 +3,10 @@ public class Player{ String name; - Double balance; - Double currentBet = 0.0; + Integer balance; + Integer currentBet = 0; - public Player(String name, Double initialDeposit) { + public Player(String name, Integer initialDeposit) { this.name = name; this.balance = initialDeposit; } @@ -17,26 +17,26 @@ public String getName() { } - public Double getBalance() { + public Integer getBalance() { return balance; } - private void setCurrentBet(Double currentBet) { + private void setCurrentBet(Integer currentBet) { this.currentBet = currentBet; } - public void setBalance(Double deposit) { + public void setBalance(Integer deposit) { this.balance = balance + deposit; } - public Double makeBet(Double betAmount) { + public Integer makeBet(Integer betAmount) { currentBet = betAmount; balance = balance - currentBet; return currentBet; } - private Double getCurrentBet() { + private Integer getCurrentBet() { return currentBet; } } From e8242784916a95b39b6689bcc48c21c29fd5930c Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 23:41:21 -0400 Subject: [PATCH 43/48] (feat:black-jack) just to be safe --- .../casino/games/blackjack/BlackJackGame.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java index 2ce25ac1d..79c6e2e54 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java @@ -71,26 +71,15 @@ public void startGame () { } break; case 2: - - - - bj.giveDealerCard(); System.out.println("The dealers first card : " + bj.dealersCurrentValue()); bj.giveDealerCard(); System.out.println("The dealer has : " + bj.dealersCurrentValue()); bj.dealersGame(); break; - - - - } - } } - - @Override From 4b6447fa6b8a008ae052d999c926162121a38547 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 13 Jul 2021 23:48:24 -0400 Subject: [PATCH 44/48] Safety check --- .../java/com/github/zipcodewilmington/casino/models/Card.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/github/zipcodewilmington/casino/models/Card.java b/src/main/java/com/github/zipcodewilmington/casino/models/Card.java index 2a4def12d..ad6c46b36 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/models/Card.java +++ b/src/main/java/com/github/zipcodewilmington/casino/models/Card.java @@ -5,6 +5,9 @@ public class Card { List cardPool; + // Let's hope this works! If you can see this, that'd be cool + // Boilage + public Card() { this.cardPool = new ArrayList<>(); this.createDeck(); From 800164ec69f67257e31f63eff614c45b138718f1 Mon Sep 17 00:00:00 2001 From: Zach Date: Wed, 14 Jul 2021 00:19:42 -0400 Subject: [PATCH 45/48] Updated player interface by removing run method, changed Double Integer on Beetle Game and BeetlePlayer --- .../casino/PlayerInterface.java | 2 +- .../casino/games/Beetle/BeetleGame.java | 28 +++++-------------- .../casino/games/Beetle/BeetlePlayer.java | 5 ++++ .../zipcodewilmington/casino/models/Card.java | 2 +- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/PlayerInterface.java b/src/main/java/com/github/zipcodewilmington/casino/PlayerInterface.java index c50b5113b..9d6800a71 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/PlayerInterface.java +++ b/src/main/java/com/github/zipcodewilmington/casino/PlayerInterface.java @@ -17,5 +17,5 @@ public interface PlayerInterface { * @param specify any return type you would like here * @return whatever return value you would like */ - SomeReturnType play(); + // SomeReturnType play(); } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java index cbc91fb07..bf2ba13e0 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java @@ -31,36 +31,20 @@ public void run(){ } } - @Override - public Integer calculateWinnings(Integer multiplier, Integer betAmount) { - return null; - } - - @Override - public void subtractBetFromBalance(Integer betAmount) { - - } - @Override - public void addMoneyToBalance(PlayerInterface Player, Integer winnings) { - } - - public String test(){ - return "NATHAN WAS HERE"; - } /** * Calculate player's winning payout amount of bet x multiplier * @return (double) amount of money winnings */ - public Double calculateWinnings(Double multiplier, Double betAmount){ - return 0.00; + public Integer calculateWinnings(Integer multiplier, Integer betAmount){ + return 0; } /** * Subtract the bet amount from player's balance */ - public void subtractBetFromBalance(Double betAmount){ + public void subtractBetFromBalance(Integer betAmount){ } @@ -68,12 +52,14 @@ public void subtractBetFromBalance(Double betAmount){ /** * Add winnings amount to player's balance */ - public void addMoneyToBalance(PlayerInterface Player, Double winnings){ + public void addMoneyToBalance(PlayerInterface Player, Integer winnings){ } - public void initGame(){ + public void initGame(Integer players){ this.game = new Beetle(this.players.size()); + this.isRunning = true; + this.run(); } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetlePlayer.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetlePlayer.java index 34b4ceb45..b4c16f59e 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetlePlayer.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetlePlayer.java @@ -1,4 +1,9 @@ package com.github.zipcodewilmington.casino.games.Beetle; public class BeetlePlayer { + private Integer bet; + + public BeetlePlayer(){ + + } } diff --git a/src/main/java/com/github/zipcodewilmington/casino/models/Card.java b/src/main/java/com/github/zipcodewilmington/casino/models/Card.java index ad6c46b36..296ce2f9a 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/models/Card.java +++ b/src/main/java/com/github/zipcodewilmington/casino/models/Card.java @@ -6,7 +6,7 @@ public class Card { List cardPool; // Let's hope this works! If you can see this, that'd be cool - // Boilage + // Boilage <== hack public Card() { this.cardPool = new ArrayList<>(); From 2f402395f8da7c73d7f02515e1f2298e77e07771 Mon Sep 17 00:00:00 2001 From: ZachSinger <32113115+ZachSinger@users.noreply.github.com> Date: Wed, 14 Jul 2021 08:19:12 -0400 Subject: [PATCH 46/48] Feature/beetle game (#34) * began implementation of BeetleGame * Moved to testing for BeetleGame, finished BeetleGame class. Cannot proceed until unneccesary @Override statements removed from BlackJack and Plinko, remove unneccessary PlayerInterface implementations Co-authored-by: Zach --- .../casino/games/Beetle/Beetle.java | 4 ++++ .../casino/games/Beetle/BeetleGame.java | 21 ++++++++++++++++++- .../github/zipcodewilmington/BeetleGame.java | 11 ++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/github/zipcodewilmington/BeetleGame.java diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/Beetle.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/Beetle.java index 56461ccc5..f205cc4d5 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/Beetle.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/Beetle.java @@ -60,6 +60,10 @@ public void setPlayerBeetles(Integer player, Integer diceRoll) { //return this.checkWinner(player); } + public void nextPlayer(){ + this.currentPlayer = (this.currentPlayer + 1) % this.numPlayers; + } + public void refreshBeetle(Integer player){ this.playerBeetles[player] = new Integer[] {0, 0, 0, 0, 0, 0}; } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java index bf2ba13e0..479423e7d 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Beetle/BeetleGame.java @@ -26,12 +26,31 @@ public void remove(PlayerInterface player){ * specifies how the game will run */ public void run(){ + Integer turnCount = 0; if(isRunning){ - + turnCount++; + this.nextPlayer(); + game.getDice().tossAndSum(); + executeTurn(); + isGameOver(game.checkWinner(game.getCurrentPlayer())); } + System.out.println("game over after " + turnCount); } + public void isGameOver(boolean playerWon){ + if(playerWon){ + isRunning = false; + } + } + public void nextPlayer(){ + game.setCurrentPlayer(-1); + game.nextPlayer(); + } + public void executeTurn(){ + Integer currentPlayer = game.getCurrentPlayer(); + game.setPlayerBeetles(currentPlayer, game.getDice().tossAndSum()); + } /** * Calculate player's winning payout amount of bet x multiplier diff --git a/src/test/java/com/github/zipcodewilmington/BeetleGame.java b/src/test/java/com/github/zipcodewilmington/BeetleGame.java new file mode 100644 index 000000000..4761cbdd3 --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/BeetleGame.java @@ -0,0 +1,11 @@ +package com.github.zipcodewilmington; + +import org.junit.Test; + +public class BeetleGame { + @Test + public void testGameOver(){ + BeetleGame game = new BeetleGame(); + + } +} From 796b2c9bbbd5fff310ef6706dd5da85dd0dfa143 Mon Sep 17 00:00:00 2001 From: Dipinti Date: Wed, 14 Jul 2021 08:29:38 -0400 Subject: [PATCH 47/48] updated plinko.java without override methods --- .../casino/games/plinko/PlinkoGame.java | 47 ++++--------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/plinko/PlinkoGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/plinko/PlinkoGame.java index c9fc6140a..e66e6d37e 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/plinko/PlinkoGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/plinko/PlinkoGame.java @@ -8,11 +8,11 @@ import java.util.Map; import java.util.Random; -public class PlinkoGame implements GameInterface,PlayerInterface { +public class PlinkoGame { private Map moneyGenerator=new HashMap(); public int initialPosition; private double betAmount; - public int randomNumber; + public int multiplier; public PlinkoGame(int initialPosition){ this.initialPosition=initialPosition; @@ -30,24 +30,13 @@ public String playPlinko(int initialPosition){ return "Invalid Entry"; } - @Override - public void add(PlayerInterface player) { - - } - - @Override - public void remove(PlayerInterface player) { - - } - - @Override - public void run() { + public void run2() { if (initialPosition < 10 && initialPosition > 0) { int max = 9; int min = 1; Random rand = new Random(); - randomNumber = rand.nextInt(max - min + 1) + min; - System.out.println("Now your position is: " + randomNumber); + multiplier = rand.nextInt(max - min + 1) + min; + System.out.println("Now your position is: " + multiplier); } else { @@ -55,8 +44,8 @@ public void run() { } } - @Override - public Double calculateWinnings(Double multiplier, Double betAmount) { + + public Double calculateWinnings2(Integer multiplier, Double betAmount) { moneyGenerator.put(1,200.00); moneyGenerator.put(2,0.00); moneyGenerator.put(3,3000.00); @@ -69,32 +58,12 @@ public Double calculateWinnings(Double multiplier, Double betAmount) { Double moneyWon=0.0; for (Integer pos:moneyGenerator.keySet()) { - if(pos.equals(randomNumber)){ + if(pos.equals(multiplier)){ moneyWon=moneyGenerator.get(pos); } } return moneyWon; } - - @Override - public void subtractBetFromBalance(Double betAmount) { - - } - - @Override - public void addMoneyToBalance(PlayerInterface Player, Double winnings) { - - } - - @Override - public CasinoAccount getArcadeAccount() { - return null; - } - - @Override - public SomeReturnType play() { - return null; - } } From f79717ed14912033c5a1ee274164bf61602d7ccc Mon Sep 17 00:00:00 2001 From: Dipinti Date: Wed, 14 Jul 2021 08:32:10 -0400 Subject: [PATCH 48/48] also updated the plinkotest without overrides --- .../java/com/github/zipcodewilmington/PlinkoTest.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/github/zipcodewilmington/PlinkoTest.java b/src/test/java/com/github/zipcodewilmington/PlinkoTest.java index 8596899de..45381a94b 100644 --- a/src/test/java/com/github/zipcodewilmington/PlinkoTest.java +++ b/src/test/java/com/github/zipcodewilmington/PlinkoTest.java @@ -9,13 +9,12 @@ public class PlinkoTest { @Test public void testCalculateWinnings() { //given - Double expectedValue=0.0; - PlinkoGame plinkoGame=new PlinkoGame(7); - plinkoGame.run(); + Double expectedValue=750.50; + PlinkoGame plinkoGame=new PlinkoGame(8); + plinkoGame.run2(); //when - Double actualValue=plinkoGame.calculateWinnings(2.00,200.00); + Double actualValue=plinkoGame.calculateWinnings2(8,200.00); //then - System.out.println(actualValue); Assert.assertEquals(expectedValue,actualValue); }