Computers and Technology

Java program Firstly you will design a class name Coin. The Coin class should have the following field: • A String named sideUp. The sideUp field will hold either ‘heads’ or ‘tails’ indicating the side of the coin that is facing up. 4 The Coin class should have the following methods: • A no-arg constructor that randomly determines the side of the coin that is facing up (‘heads’ or ‘tails’) and initializes the sideUp field accordingly. • A void method named toss that simulates the tossing of the coin. When the toss method is called, it randomly determines the side of the coin that is facing up (‘heads’ or ‘tails’) and sets the sideUp field accordingly. • A method named getSideUp that returns the value of the sideUp field. Secondly, you will implement the ‘Heads or Tails’ game. This game is meant for two or more players. In this game, the players take turns flipping a coin. Before the coin is flipped, players should guess if the coin will land face up or face down. If a player guesses correctly, then the player is awarded one point. If a player guesses incorrectly, then the player will lose a point. The first player to score three points is the winner. Write a program named HeadsOrTailsGame. java that simulates the game being played by two players. Use the Coin class that your previously wrote to simulate the coin. Also write the Player class to simulate the players.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 01:10, shimmerandshine1
When you reach a yield sign, yield to cross traffic and before you enter the intersection. a. flash your headlights b. wait for a signal c. wait five seconds d. wait for a safe gap
Answers: 1
image
Computers and Technology, 22.06.2019 02:30, rodfam13716
If you turn on the lock alpha button , what happens
Answers: 1
image
Computers and Technology, 23.06.2019 02:00, kelseybell5522
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 1
image
Computers and Technology, 23.06.2019 03:00, Julianhooks
State 7 common key's for every keyboard
Answers: 1
Do you know the correct answer?
Java program Firstly you will design a class name Coin. The Coin class should have the following fi...

Questions in other subjects: