From b0ecd8e3163d20b22b0eb92b66cba3743e085366 Mon Sep 17 00:00:00 2001 From: Nhu Nguyen Date: Tue, 26 Feb 2019 13:04:52 -0500 Subject: [PATCH 1/6] added instructions --- src/main/java/io/zipcoder/casino/Casino.java | 10 ++- src/main/java/io/zipcoder/casino/Game.java | 6 ++ src/main/java/io/zipcoder/casino/Player.java | 25 ++++++++ .../casino/blackjack/BlackJackConsole.java | 18 ++++++ .../casino/blackjack/BlackJackGame.java | 62 +++++++++++++++++++ .../casino/blackjack/BlackJackRule.java | 21 +++++++ .../io/zipcoder/casino/blackjack/Card.java | 9 +++ .../zipcoder/casino/blackjack/CardPlayer.java | 13 ++++ .../io/zipcoder/casino/blackjack/Deck.java | 31 ++++++++++ .../zipcoder/casino/blackjack/FaceValue.java | 7 +++ .../io/zipcoder/casino/blackjack/Suite.java | 5 ++ .../casino/chuckaluck/ChuckALuckConsole.java | 24 +++++++ .../casino/chuckaluck/ChuckALuckGame.java | 45 ++++++++++++++ .../io/zipcoder/casino/chuckaluck/Dice.java | 18 ++++++ 14 files changed, 293 insertions(+), 1 deletion(-) create mode 100644 src/main/java/io/zipcoder/casino/Game.java create mode 100644 src/main/java/io/zipcoder/casino/Player.java create mode 100644 src/main/java/io/zipcoder/casino/blackjack/BlackJackConsole.java create mode 100644 src/main/java/io/zipcoder/casino/blackjack/BlackJackGame.java create mode 100644 src/main/java/io/zipcoder/casino/blackjack/BlackJackRule.java create mode 100644 src/main/java/io/zipcoder/casino/blackjack/Card.java create mode 100644 src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java create mode 100644 src/main/java/io/zipcoder/casino/blackjack/Deck.java create mode 100644 src/main/java/io/zipcoder/casino/blackjack/FaceValue.java create mode 100644 src/main/java/io/zipcoder/casino/blackjack/Suite.java create mode 100644 src/main/java/io/zipcoder/casino/chuckaluck/ChuckALuckConsole.java create mode 100644 src/main/java/io/zipcoder/casino/chuckaluck/ChuckALuckGame.java create mode 100644 src/main/java/io/zipcoder/casino/chuckaluck/Dice.java diff --git a/src/main/java/io/zipcoder/casino/Casino.java b/src/main/java/io/zipcoder/casino/Casino.java index 16ca0dd74..59a701641 100644 --- a/src/main/java/io/zipcoder/casino/Casino.java +++ b/src/main/java/io/zipcoder/casino/Casino.java @@ -3,6 +3,14 @@ public class Casino { public static void main(String[] args) { - // write your tests before you start fucking with this + //Hi welcome to casino. + //what's your name + //how much money do you have + + //print out the two games + //what game do you want to play + //create the game + //play the game + //do you want to play again? } } diff --git a/src/main/java/io/zipcoder/casino/Game.java b/src/main/java/io/zipcoder/casino/Game.java new file mode 100644 index 000000000..b3ea721e1 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Game.java @@ -0,0 +1,6 @@ +package io.zipcoder.casino; + +public interface Game { + + void play(); +} diff --git a/src/main/java/io/zipcoder/casino/Player.java b/src/main/java/io/zipcoder/casino/Player.java new file mode 100644 index 000000000..1727604dd --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Player.java @@ -0,0 +1,25 @@ +package io.zipcoder.casino; + +public class Player { + + //declare a field of type String named name + //declare a field of type double named money + + //create a constructor that takes a name + // and set it to the field name + + //create a constructor that takes a name + // and money. Set them to their fields + + //create a getter and setter for both fields + + //create a method called addMoney which + // takes in a double named amount. + // the method will add the amount to the + // money + + //create a method called pay which + //takes a double named amount + //the method will substract the amount from + //the money +} diff --git a/src/main/java/io/zipcoder/casino/blackjack/BlackJackConsole.java b/src/main/java/io/zipcoder/casino/blackjack/BlackJackConsole.java new file mode 100644 index 000000000..ba041fc5a --- /dev/null +++ b/src/main/java/io/zipcoder/casino/blackjack/BlackJackConsole.java @@ -0,0 +1,18 @@ +package io.zipcoder.casino.blackjack; + +public class BlackJackConsole { + //define a field of type Console named console + + //create a static method that takes in + // a List + // the method will display the suite + // and face value of card + + //create a method that will + + //create a method called printResult which + //takes in String param and a double amount + // if the String is "win" say "You won $amount" + // if the string is "lose" say "You lost $amount" + // else say "it's a draw" +} diff --git a/src/main/java/io/zipcoder/casino/blackjack/BlackJackGame.java b/src/main/java/io/zipcoder/casino/blackjack/BlackJackGame.java new file mode 100644 index 000000000..2dc60a31a --- /dev/null +++ b/src/main/java/io/zipcoder/casino/blackjack/BlackJackGame.java @@ -0,0 +1,62 @@ +package io.zipcoder.casino.blackjack; + +import io.zipcoder.casino.Player; + +// implements Game +public class BlackJackGame { + //declare a field of type Player named dealer + //declare a field of type Player named player + //declare a field of type Deck named deck + //declare a field of type double named playerBet + //declare a field of type BlackJackConsole named console + + //create a constructor that takes in a + // CardPlayer, Deck, and BlackJackConsole + // set the fields to the params + + // create a constructor that takes in a + // CardPlayer and a BlackJackConsole + // set the fields to the params + // Create a new Deck and set it to the deck field + + + //create a method named play with no return type or parameter + public void play(){ + //deal cards + //show player their cards + // ask them how much they want to bet + // store the result in the playerBet + //call takeTurn(player) + //call takeTurn(dealer) + //check if the player win by calling + //BlackJackRule.getResult and give it + // the player hand and the dealer hand + // if the result return "win" + // then addMoney to the player with + // the playerBet amount + // if result return "lose" then + // ask the player to pay the playerBet amount + // print dealer hand + // print the player hand + // call console.printResult with + // the result and playerBet + + } + + //create a method named deal with no return type + public void deal(Deck deck, CardPlayer... players){ + + } + + //create a method named takeTurn that takes in + //player and return nothing + // the method will: + //in a while loop + // ask if they want to draw + // if they say no, exit the loop + // else add a card to the player hand + // call BlackJackRule to checks if + // it's busted? + // if it's busted, exit the loop + +} diff --git a/src/main/java/io/zipcoder/casino/blackjack/BlackJackRule.java b/src/main/java/io/zipcoder/casino/blackjack/BlackJackRule.java new file mode 100644 index 000000000..098bf9858 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/blackjack/BlackJackRule.java @@ -0,0 +1,21 @@ +package io.zipcoder.casino.blackjack; + +public class BlackJackRule { + + //create a static method called isBusted + //takes in a List named hand + //checks to see if the hand is busted + //a hand is busted if it's over 21 + //ace can be 1 or 11 + // 10, Jack, Queen, King are 10 + + //create a static method named getResult + // that takes in two List + // and return a String + // return "win" if the first hand + // is higher but not busted + // return "lose" if the first hand is + // less than the second hand + // return "draw" if both hands are equal + // or if both hands are busted +} diff --git a/src/main/java/io/zipcoder/casino/blackjack/Card.java b/src/main/java/io/zipcoder/casino/blackjack/Card.java new file mode 100644 index 000000000..c38e596ec --- /dev/null +++ b/src/main/java/io/zipcoder/casino/blackjack/Card.java @@ -0,0 +1,9 @@ +package io.zipcoder.casino.blackjack; + +public class Card { + //declare a field of type Suite named suite + //declare a field of type FaceValue named faceValue + + //create a getter and setter for both fields + +} diff --git a/src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java b/src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java new file mode 100644 index 000000000..0874031a9 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java @@ -0,0 +1,13 @@ +package io.zipcoder.casino.blackjack; + +//extends from the player +public class CardPlayer { + //create a field of type List named hand + + // create a method named add that takes a + // card and add it to the list cards + // it does not return anything + + //create a method named getHand that takes + // in no param and return the player hand +} diff --git a/src/main/java/io/zipcoder/casino/blackjack/Deck.java b/src/main/java/io/zipcoder/casino/blackjack/Deck.java new file mode 100644 index 000000000..81bad905d --- /dev/null +++ b/src/main/java/io/zipcoder/casino/blackjack/Deck.java @@ -0,0 +1,31 @@ +package io.zipcoder.casino.blackjack; + +public class Deck { + //create a field of type List named cards + + //create an empty constructor + //in the body of the constructor initialize + // the list to a new ArrayList + // call the method generate to generate a deck of card + + // create a method named generate that takes in no params + // and return nothing + // this method will generate all 52 cards + + + + // create a method named add that takes a + // card and add it to the list cards + // it does not return anything + + + //create a method named draw that takes in + //no param and return a card + //the method will remove a card from the list + // at index 0 + + //create a method called shuffle + //no return, no param + // it will call the method shuffle from + // the Collections class +} diff --git a/src/main/java/io/zipcoder/casino/blackjack/FaceValue.java b/src/main/java/io/zipcoder/casino/blackjack/FaceValue.java new file mode 100644 index 000000000..8885842a2 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/blackjack/FaceValue.java @@ -0,0 +1,7 @@ +package io.zipcoder.casino.blackjack; + +public enum FaceValue { + ACE, TWO, THREE, FOUR, FIVE, SIX, + SEVEN, EIGHT, NINE, TEN, JACK, + QUEEN, KING; +} diff --git a/src/main/java/io/zipcoder/casino/blackjack/Suite.java b/src/main/java/io/zipcoder/casino/blackjack/Suite.java new file mode 100644 index 000000000..86f11ac8d --- /dev/null +++ b/src/main/java/io/zipcoder/casino/blackjack/Suite.java @@ -0,0 +1,5 @@ +package io.zipcoder.casino.blackjack; + +public enum Suite { + DIAMONDS, CLUBS, HEART, SPADES; +} diff --git a/src/main/java/io/zipcoder/casino/chuckaluck/ChuckALuckConsole.java b/src/main/java/io/zipcoder/casino/chuckaluck/ChuckALuckConsole.java new file mode 100644 index 000000000..176185759 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/chuckaluck/ChuckALuckConsole.java @@ -0,0 +1,24 @@ +package io.zipcoder.casino.chuckaluck; + +public class ChuckALuckConsole { + //define a field of type Console named console + + + //create a method named getNumber + // that takes in no param and return an int + // it will ask the user for a number + // and return the number the user enter + + + + //create a method named printResult that takes + // List and print out + // dice 1 is + // dice 2 is + // dice 3 is + + + + + +} diff --git a/src/main/java/io/zipcoder/casino/chuckaluck/ChuckALuckGame.java b/src/main/java/io/zipcoder/casino/chuckaluck/ChuckALuckGame.java new file mode 100644 index 000000000..f5d21b9e2 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/chuckaluck/ChuckALuckGame.java @@ -0,0 +1,45 @@ +package io.zipcoder.casino.chuckaluck; + +//implements Game +public class ChuckALuckGame { + //create a field of type Player named player + //create a field of type double named playerBet + // create a field of type List named userGuesses + // create a field of type List named results + + //create a constructor that takes in a player + // in the constructor, set the player to the player field + // initialize the userGuesses and results to ArrayList + + + + + //create a method named play that takes in + // no parameter and does not return anything + // same method signature as the Game interface + //this method will: + // ask player for 3 numbers + // store the player answer in the userGuesses + // roll a dice 3 times + // add the result of the dice to the results list + // call the ChuckALuckConsole to print out the user guesses + // Call the ChuckALuckConsole print out the dice results + // if the matches is 2, then call player to addMoney + // with the playerBet amount + // if the matches is 3, then call player to addMoney + // with twice the amount of the playerBet + // if the match is 0, then call player to pay + // the playerBet amount + // Call ChuckALuckConsole.printResult to print out result + + + + //create a method named getMatches that takes in + // no params and return an int + // the method will count how many number in + // the userGuesses matches the results + // return the count + + + +} diff --git a/src/main/java/io/zipcoder/casino/chuckaluck/Dice.java b/src/main/java/io/zipcoder/casino/chuckaluck/Dice.java new file mode 100644 index 000000000..5fef363ac --- /dev/null +++ b/src/main/java/io/zipcoder/casino/chuckaluck/Dice.java @@ -0,0 +1,18 @@ +package io.zipcoder.casino.chuckaluck; + +public class Dice { + + //declare a field of type Random named random + + //create an empty constructor + //in the body, set the field random to + // a new Random instance + + //create a constructor that takes a Random + //set the random to the field + + //create a method named roll that takes + //no param and return an int + //the method will call nextInt on random + // the number should be between 1 - 6 +} From ea710a35a48b4f73c832bf0aad5e45bf1878c584 Mon Sep 17 00:00:00 2001 From: Nhu Nguyen Date: Tue, 26 Feb 2019 16:25:44 -0500 Subject: [PATCH 2/6] update code --- .../zipcoder/casino/blackjack/BlackJackConsole.java | 3 +-- .../io/zipcoder/casino/blackjack/BlackJackRule.java | 4 ++-- .../java/io/zipcoder/casino/blackjack/CardPlayer.java | 2 ++ .../java/io/zipcoder/casino/blackjack/CardTest.java | 11 +++++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 src/test/java/io/zipcoder/casino/blackjack/CardTest.java diff --git a/src/main/java/io/zipcoder/casino/blackjack/BlackJackConsole.java b/src/main/java/io/zipcoder/casino/blackjack/BlackJackConsole.java index ba041fc5a..0fa2840ef 100644 --- a/src/main/java/io/zipcoder/casino/blackjack/BlackJackConsole.java +++ b/src/main/java/io/zipcoder/casino/blackjack/BlackJackConsole.java @@ -3,12 +3,11 @@ public class BlackJackConsole { //define a field of type Console named console - //create a static method that takes in + //create a method that takes in // a List // the method will display the suite // and face value of card - //create a method that will //create a method called printResult which //takes in String param and a double amount diff --git a/src/main/java/io/zipcoder/casino/blackjack/BlackJackRule.java b/src/main/java/io/zipcoder/casino/blackjack/BlackJackRule.java index 098bf9858..7dde813cb 100644 --- a/src/main/java/io/zipcoder/casino/blackjack/BlackJackRule.java +++ b/src/main/java/io/zipcoder/casino/blackjack/BlackJackRule.java @@ -2,14 +2,14 @@ public class BlackJackRule { - //create a static method called isBusted + //create a method called isBusted //takes in a List named hand //checks to see if the hand is busted //a hand is busted if it's over 21 //ace can be 1 or 11 // 10, Jack, Queen, King are 10 - //create a static method named getResult + //create a method named getResult // that takes in two List // and return a String // return "win" if the first hand diff --git a/src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java b/src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java index 0874031a9..eee0e8a0f 100644 --- a/src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java +++ b/src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java @@ -1,5 +1,7 @@ package io.zipcoder.casino.blackjack; +import io.zipcoder.casino.Player; + //extends from the player public class CardPlayer { //create a field of type List named hand diff --git a/src/test/java/io/zipcoder/casino/blackjack/CardTest.java b/src/test/java/io/zipcoder/casino/blackjack/CardTest.java new file mode 100644 index 000000000..966da4857 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/blackjack/CardTest.java @@ -0,0 +1,11 @@ +package io.zipcoder.casino.blackjack; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class CardTest { + + + +} \ No newline at end of file From 0938dbce6530a3b3539b350fee41066a3c987b95 Mon Sep 17 00:00:00 2001 From: Robyn Graham Date: Tue, 26 Feb 2019 18:28:02 -0500 Subject: [PATCH 3/6] done --- src/main/java/io/zipcoder/casino/Player.java | 45 +++++++++++++++++++ .../zipcoder/casino/blackjack/CardPlayer.java | 29 +++++++++++- .../java/io/zipcoder/casino/PlayerTest.java | 24 ++++++++++ 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 src/test/java/io/zipcoder/casino/PlayerTest.java diff --git a/src/main/java/io/zipcoder/casino/Player.java b/src/main/java/io/zipcoder/casino/Player.java index 1727604dd..854da5e83 100644 --- a/src/main/java/io/zipcoder/casino/Player.java +++ b/src/main/java/io/zipcoder/casino/Player.java @@ -22,4 +22,49 @@ public class Player { //takes a double named amount //the method will substract the amount from //the money + + private String name; + private double money; + + public Player (String name) { + + this.name = name; + } + + public Player (String name, double money) { + + this.name = name; + this.money = money; + + } + + public void setName(String playerone) { + + this.name = playerone; + + } + + public String getName(){ + + return name; + } + + public double getMoney() { + return money; + } + //add a getter for money + + public double addMoney(double amount1){ + money = money + amount1; + return money; + } + + public double pay(double amount2){ + money = money - amount2; + return money; + + } + + } + diff --git a/src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java b/src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java index eee0e8a0f..e12153eba 100644 --- a/src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java +++ b/src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java @@ -2,8 +2,11 @@ import io.zipcoder.casino.Player; +import java.util.ArrayList; +import java.util.List; + //extends from the player -public class CardPlayer { +public class CardPlayer extends Player { //create a field of type List named hand // create a method named add that takes a @@ -12,4 +15,26 @@ public class CardPlayer { //create a method named getHand that takes // in no param and return the player hand -} + + + List hand = new ArrayList(); + + public CardPlayer(String name) { + super(name); + } + + public CardPlayer(String name, double money) { + super(name, money); + } + + + public void add(Card card) { + hand.add(card); + } + + public List getHand() { + + return hand; + + } +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/PlayerTest.java b/src/test/java/io/zipcoder/casino/PlayerTest.java new file mode 100644 index 000000000..6242dfa37 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/PlayerTest.java @@ -0,0 +1,24 @@ +package io.zipcoder.casino; + +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class PlayerTest { + + @Test + public void testGetSetName(){ + //given - setting up data + Player player = new Player("Robyn"); + String expected = "Bob"; + + //when - when you call the method test + player.setName("Bob"); + String actual = player.getName(); + + Assert.assertEquals(expected, actual); + + } + +} \ No newline at end of file From d0c3e94c9d631b0a621e0ae02b20a6571fdecf06 Mon Sep 17 00:00:00 2001 From: Ashley Renee Smith Date: Tue, 26 Feb 2019 22:01:43 -0500 Subject: [PATCH 4/6] first commit , still have to add more. --- .../casino/blackjack/BlackJackGame.java | 124 +++++++++--------- .../io/zipcoder/casino/blackjack/Deck.java | 66 +++++++--- .../io/zipcoder/casino/chuckaluck/Dice.java | 56 +++++++- .../zipcoder/casino/blackjack/DiceTest.java | 43 ++++++ 4 files changed, 199 insertions(+), 90 deletions(-) create mode 100644 src/test/java/io/zipcoder/casino/blackjack/DiceTest.java diff --git a/src/main/java/io/zipcoder/casino/blackjack/BlackJackGame.java b/src/main/java/io/zipcoder/casino/blackjack/BlackJackGame.java index 2dc60a31a..eed1ec1dd 100644 --- a/src/main/java/io/zipcoder/casino/blackjack/BlackJackGame.java +++ b/src/main/java/io/zipcoder/casino/blackjack/BlackJackGame.java @@ -1,62 +1,62 @@ -package io.zipcoder.casino.blackjack; - -import io.zipcoder.casino.Player; - -// implements Game -public class BlackJackGame { - //declare a field of type Player named dealer - //declare a field of type Player named player - //declare a field of type Deck named deck - //declare a field of type double named playerBet - //declare a field of type BlackJackConsole named console - - //create a constructor that takes in a - // CardPlayer, Deck, and BlackJackConsole - // set the fields to the params - - // create a constructor that takes in a - // CardPlayer and a BlackJackConsole - // set the fields to the params - // Create a new Deck and set it to the deck field - - - //create a method named play with no return type or parameter - public void play(){ - //deal cards - //show player their cards - // ask them how much they want to bet - // store the result in the playerBet - //call takeTurn(player) - //call takeTurn(dealer) - //check if the player win by calling - //BlackJackRule.getResult and give it - // the player hand and the dealer hand - // if the result return "win" - // then addMoney to the player with - // the playerBet amount - // if result return "lose" then - // ask the player to pay the playerBet amount - // print dealer hand - // print the player hand - // call console.printResult with - // the result and playerBet - - } - - //create a method named deal with no return type - public void deal(Deck deck, CardPlayer... players){ - - } - - //create a method named takeTurn that takes in - //player and return nothing - // the method will: - //in a while loop - // ask if they want to draw - // if they say no, exit the loop - // else add a card to the player hand - // call BlackJackRule to checks if - // it's busted? - // if it's busted, exit the loop - -} +//package io.zipcoder.casino.blackjack; +// +//import io.zipcoder.casino.Player; +// +//// implements Game +//public class BlackJackGame { +// //declare a field of type Player named dealer +// //declare a field of type Player named player +// //declare a field of type Deck named deck +// //declare a field of type double named playerBet +// //declare a field of type BlackJackConsole named console +// +// //create a constructor that takes in a +// // CardPlayer, Deck, and BlackJackConsole +// // set the fields to the params +// +// // create a constructor that takes in a +// // CardPlayer and a BlackJackConsole +// // set the fields to the params +// // Create a new Deck and set it to the deck field +// +// +// //create a method named play with no return type or parameter +// public void play(){ +// //deal cards +// //show player their cards +// // ask them how much they want to bet +// // store the result in the playerBet +// //call takeTurn(player) +// //call takeTurn(dealer) +// //check if the player win by calling +// //BlackJackRule.getResult and give it +// // the player hand and the dealer hand +// // if the result return "win" +// // then addMoney to the player with +// // the playerBet amount +// // if result return "lose" then +// // ask the player to pay the playerBet amount +// // print dealer hand +// // print the player hand +// // call console.printResult with +// // the result and playerBet +// +// } +// +// //create a method named deal with no return type +// // public void deal(Deck deck, CardPlayer... players){ +// +// } +// +// //create a method named takeTurn that takes in +// //player and return nothing +// // the method will: +// //in a while loop +// // ask if they want to draw +// // if they say no, exit the loop +// // else add a card to the player hand +// // call BlackJackRule to checks if +// // it's busted? +// // if it's busted, exit the loop +// +//} diff --git a/src/main/java/io/zipcoder/casino/blackjack/Deck.java b/src/main/java/io/zipcoder/casino/blackjack/Deck.java index 81bad905d..f7adca59e 100644 --- a/src/main/java/io/zipcoder/casino/blackjack/Deck.java +++ b/src/main/java/io/zipcoder/casino/blackjack/Deck.java @@ -1,31 +1,55 @@ package io.zipcoder.casino.blackjack; +import java.util.ArrayList; +import java.util.List; +; +import java.util.Stack; + public class Deck { //create a field of type List named cards + private Stack deckOfCards; + private int numberOfCards; + private String faceType; + private Card cards[]; //create an empty constructor //in the body of the constructor initialize // the list to a new ArrayList // call the method generate to generate a deck of card - // create a method named generate that takes in no params - // and return nothing - // this method will generate all 52 cards - - - - // create a method named add that takes a - // card and add it to the list cards - // it does not return anything - - - //create a method named draw that takes in - //no param and return a card - //the method will remove a card from the list - // at index 0 - - //create a method called shuffle - //no return, no param - // it will call the method shuffle from - // the Collections class -} + public Deck() { + List deckOfCards = new ArrayList(); + } + // create a method named generate that takes in no params + // and return nothing + // this method will generate all 52 cards + public void generate() { + + this.cards = new Card[52]; + for (int i = 0; i < cards.length ; i++) { + + } + } + // create a method named add that takes a + // card and add it to the list cards + // it does not return anything + public void addCardToHand(Card card) { + deckOfCards.add(card); + + } + //create a method named draw that takes in + //no param and return a card + //the method will remove a card from the list + // at index 0 + public Card draw() { + deckOfCards.remove(0); + return draw(); + } + //create a method called shuffle + //no return, no param + // it will call the method shuffle from + // the Collections class + public void shuffle(){ + + } +} \ No newline at end of file diff --git a/src/main/java/io/zipcoder/casino/chuckaluck/Dice.java b/src/main/java/io/zipcoder/casino/chuckaluck/Dice.java index 5fef363ac..473883595 100644 --- a/src/main/java/io/zipcoder/casino/chuckaluck/Dice.java +++ b/src/main/java/io/zipcoder/casino/chuckaluck/Dice.java @@ -1,18 +1,60 @@ package io.zipcoder.casino.chuckaluck; +import java.util.ArrayList; +import java.util.Random; + public class Dice { //declare a field of type Random named random + + private int numbersOfDice; + Random random; + private ArrayList tossResults; + private int roll; + + //create an empty constructor + + public Dice() { + Random randomroll = new Random(); + } //in the body, set the field random to // a new Random instance - //create a constructor that takes a Random - //set the random to the field + public int roll() { + return random.nextInt(6); + } + + public void toss() { + tossResults.clear(); + for (int i = 1; i <= numbersOfDice; i++) { + tossResults.add(randomDiceToss()); + } + } + + public Integer getSum() { + Integer sum = 0; + for (int result : tossResults) { + sum = sum + result; + } + return sum; + } + + private int randomDiceToss() { + return random.nextInt(6); + } + + public Integer[] getResults() { + return getResults(); + + //create a constructor that takes a Random + //set the random to the field + + //create a method named roll that takes + //no param and return an int + //the method will call nextInt on random + // the number should be between 1 - 6 + } - //create a method named roll that takes - //no param and return an int - //the method will call nextInt on random - // the number should be between 1 - 6 -} +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/blackjack/DiceTest.java b/src/test/java/io/zipcoder/casino/blackjack/DiceTest.java new file mode 100644 index 000000000..70a1b4b71 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/blackjack/DiceTest.java @@ -0,0 +1,43 @@ +package io.zipcoder.casino.blackjack; + + +import io.zipcoder.casino.chuckaluck.Dice; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Random; + + +public class DiceTest { + + @Test + public void roll() { + } + + @Test + public void toss() { + } + + @Test + public void getSum() { + } + + @Test + public void getResults() { + } + @Test + public void addCardToHand(){ + + } + @Test + public void draw(){ + + + } + @Test + public void shuffle(){ + + } + +} + From a89664995475ad22f6ed8908331a05597b570484 Mon Sep 17 00:00:00 2001 From: Ashley Renee Smith Date: Tue, 26 Feb 2019 22:09:20 -0500 Subject: [PATCH 5/6] made a few minor changes --- src/main/java/io/zipcoder/casino/blackjack/Deck.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/zipcoder/casino/blackjack/Deck.java b/src/main/java/io/zipcoder/casino/blackjack/Deck.java index f7adca59e..a3664109a 100644 --- a/src/main/java/io/zipcoder/casino/blackjack/Deck.java +++ b/src/main/java/io/zipcoder/casino/blackjack/Deck.java @@ -43,6 +43,8 @@ public void addCardToHand(Card card) { // at index 0 public Card draw() { deckOfCards.remove(0); + deckOfCards.size(); + return draw(); } //create a method called shuffle From 43a86d96c57cfdcc1c2352669e8e01c4c59e1e74 Mon Sep 17 00:00:00 2001 From: Nhu Nguyen Date: Tue, 26 Feb 2019 22:33:30 -0500 Subject: [PATCH 6/6] fixed blackjack --- .../casino/blackjack/BlackJackGame.java | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/src/main/java/io/zipcoder/casino/blackjack/BlackJackGame.java b/src/main/java/io/zipcoder/casino/blackjack/BlackJackGame.java index eed1ec1dd..2dc60a31a 100644 --- a/src/main/java/io/zipcoder/casino/blackjack/BlackJackGame.java +++ b/src/main/java/io/zipcoder/casino/blackjack/BlackJackGame.java @@ -1,62 +1,62 @@ -//package io.zipcoder.casino.blackjack; -// -//import io.zipcoder.casino.Player; -// -//// implements Game -//public class BlackJackGame { -// //declare a field of type Player named dealer -// //declare a field of type Player named player -// //declare a field of type Deck named deck -// //declare a field of type double named playerBet -// //declare a field of type BlackJackConsole named console -// -// //create a constructor that takes in a -// // CardPlayer, Deck, and BlackJackConsole -// // set the fields to the params -// -// // create a constructor that takes in a -// // CardPlayer and a BlackJackConsole -// // set the fields to the params -// // Create a new Deck and set it to the deck field -// -// -// //create a method named play with no return type or parameter -// public void play(){ -// //deal cards -// //show player their cards -// // ask them how much they want to bet -// // store the result in the playerBet -// //call takeTurn(player) -// //call takeTurn(dealer) -// //check if the player win by calling -// //BlackJackRule.getResult and give it -// // the player hand and the dealer hand -// // if the result return "win" -// // then addMoney to the player with -// // the playerBet amount -// // if result return "lose" then -// // ask the player to pay the playerBet amount -// // print dealer hand -// // print the player hand -// // call console.printResult with -// // the result and playerBet -// -// } -// -// //create a method named deal with no return type -// // public void deal(Deck deck, CardPlayer... players){ -// -// } -// -// //create a method named takeTurn that takes in -// //player and return nothing -// // the method will: -// //in a while loop -// // ask if they want to draw -// // if they say no, exit the loop -// // else add a card to the player hand -// // call BlackJackRule to checks if -// // it's busted? -// // if it's busted, exit the loop -// -//} +package io.zipcoder.casino.blackjack; + +import io.zipcoder.casino.Player; + +// implements Game +public class BlackJackGame { + //declare a field of type Player named dealer + //declare a field of type Player named player + //declare a field of type Deck named deck + //declare a field of type double named playerBet + //declare a field of type BlackJackConsole named console + + //create a constructor that takes in a + // CardPlayer, Deck, and BlackJackConsole + // set the fields to the params + + // create a constructor that takes in a + // CardPlayer and a BlackJackConsole + // set the fields to the params + // Create a new Deck and set it to the deck field + + + //create a method named play with no return type or parameter + public void play(){ + //deal cards + //show player their cards + // ask them how much they want to bet + // store the result in the playerBet + //call takeTurn(player) + //call takeTurn(dealer) + //check if the player win by calling + //BlackJackRule.getResult and give it + // the player hand and the dealer hand + // if the result return "win" + // then addMoney to the player with + // the playerBet amount + // if result return "lose" then + // ask the player to pay the playerBet amount + // print dealer hand + // print the player hand + // call console.printResult with + // the result and playerBet + + } + + //create a method named deal with no return type + public void deal(Deck deck, CardPlayer... players){ + + } + + //create a method named takeTurn that takes in + //player and return nothing + // the method will: + //in a while loop + // ask if they want to draw + // if they say no, exit the loop + // else add a card to the player hand + // call BlackJackRule to checks if + // it's busted? + // if it's busted, exit the loop + +}