subject

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.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 16:00
Choice of type is influenced primarily by these two factors?
Answers: 3
question
Computers and Technology, 22.06.2019 18:10
Assume that to_the_power_of is a function that expects two int parameters and returns the value of the first parameter raised to the power of the second parameter. write a statement that calls to_the_power_of to compute the value of cube_side raised to the power of 3 and that associates this value with cube_volume.
Answers: 1
question
Computers and Technology, 22.06.2019 19:20
Terri needs to insert a cover page into her document. where should she go to access the commands to do so? o insert tab, objects group o insert tab, illustrations group o insert tab, pages group o insert tab, media group submit
Answers: 1
question
Computers and Technology, 22.06.2019 19:20
Amedian in the road will be marked with a white sign that has a black arrow going to the left of the median. true false
Answers: 1
You know the right answer?
Java program Firstly you will design a class name Coin. The Coin class should have the following fi...
Questions
question
Mathematics, 31.07.2019 03:00
Questions on the website: 13722359