HWJ7_Random
You are going to create a class called HWJ7_Random extends BorlandBase that will either
flip a coin, roll a dice, or receive a card.
Everybody do 4, advanced do all plus one extension:
- a method called flipCoin that will flip a coin, System.out.println
the results, AND return a boolean (true for heads, false for tails)
- a method called rollDice that will roll one die, System.out.println
the results, AND return the number rolled.
- a method called roll2Dice that will roll 2 dice, System.out.println
the results of each die, AND return an int with the sum of the
outcome (2-12). I want you to call rollDice in this method.
- a method called public void rollPlayingGame that will take in two parameters (int strength1, int strength2) -> Then simulate rolling a die with strength1 sides, and simulate a roll of die with strength2 sides. However is bigger wins. it will then say player1, player2 or tie for whoever wins.
- method called dealCard that will choose a random card, System.out.println
the results, AND return a String with the outcome (ie 6 of hearts)
- method public String rockPaperScissors (String handOption) that will take in as handOption "rock" "paper" "scissors" and it will have the computer randomly throw down rock, paper or scissors and return who won.
6 POINTS DUE Tomorrow
-
Extension - For advanced
- a new method that says analyzeRolls that will take in an
int and roll the die that many times, at the end, it is to
say how many 1,2,3,4,5,6 were rolled and percentages of each
- a new method that says analyze2Rolls that will take in an
int and roll the die that many times, at the end, it is to
say how many 2-12 were rolled and percentages of each
|