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..854da5e83 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Player.java @@ -0,0 +1,70 @@ +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 + + 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/BlackJackConsole.java b/src/main/java/io/zipcoder/casino/blackjack/BlackJackConsole.java new file mode 100644 index 000000000..0fa2840ef --- /dev/null +++ b/src/main/java/io/zipcoder/casino/blackjack/BlackJackConsole.java @@ -0,0 +1,17 @@ +package io.zipcoder.casino.blackjack; + +public class BlackJackConsole { + //define a field of type Console named console + + //create a method that takes in + // a List + // the method will display the suite + // and face value of card + + + //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..7dde813cb --- /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 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 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..e12153eba --- /dev/null +++ b/src/main/java/io/zipcoder/casino/blackjack/CardPlayer.java @@ -0,0 +1,40 @@ +package io.zipcoder.casino.blackjack; + +import io.zipcoder.casino.Player; + +import java.util.ArrayList; +import java.util.List; + +//extends from the player +public class CardPlayer extends Player { + //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 + + + 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/main/java/io/zipcoder/casino/blackjack/Deck.java b/src/main/java/io/zipcoder/casino/blackjack/Deck.java new file mode 100644 index 000000000..a3664109a --- /dev/null +++ b/src/main/java/io/zipcoder/casino/blackjack/Deck.java @@ -0,0 +1,57 @@ +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 + + 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); + deckOfCards.size(); + + 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/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..473883595 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/chuckaluck/Dice.java @@ -0,0 +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 + + 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 + } + +} \ 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 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 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(){ + + } + +} +