Hey guys,
First off all I'm not looking for you to write the program but rather just show me the right direction to go.
"Using the coin class design, implement a driver class called 'FlipRace' whose main method creates 2 coin objects, then continually flips them both to see which coin first comes up heads 3 times in a row. Continue flipping until one of the coins wins, and consider they may tie. Print the results of each turn, print the winner, and print the total flips required."
Okay, so far I created the main class FlipRace and another class CoinFlip, so I have nothing. I know I need the 2 coin objects, but I'm not sure if I put them in the driver class or the class where my main block of code will be that flips and reports the results (my guess is the latter)
Since it flips until 3 heads in a row, I believe I need to use an if statement or a for loop. I also think the random package should be imported and used somehow but I'm having trouble putting this all together.
Can anyone point me in the right direction, or offer anything to get me started?
Much appreciated
First off all I'm not looking for you to write the program but rather just show me the right direction to go.
"Using the coin class design, implement a driver class called 'FlipRace' whose main method creates 2 coin objects, then continually flips them both to see which coin first comes up heads 3 times in a row. Continue flipping until one of the coins wins, and consider they may tie. Print the results of each turn, print the winner, and print the total flips required."
Okay, so far I created the main class FlipRace and another class CoinFlip, so I have nothing. I know I need the 2 coin objects, but I'm not sure if I put them in the driver class or the class where my main block of code will be that flips and reports the results (my guess is the latter)
Since it flips until 3 heads in a row, I believe I need to use an if statement or a for loop. I also think the random package should be imported and used somehow but I'm having trouble putting this all together.
Can anyone point me in the right direction, or offer anything to get me started?
Much appreciated