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, 23.06.2019 01:30
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: 2
question
Computers and Technology, 23.06.2019 12:00
Which of these is an example of an integrated presentation? a. a table created in powerpoint b. an image pasted into powerpoint c. a caption created in powerpoint d. an excel chart pasted into powerpoint
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
Write a program that prints the day number of the year, given the date in the form month-day-year. for example, if the input is 1-1-2006, the day number is 1; if the input is 12-25-2006, the day number is 359. the program should check for a leap year. a year is a leap year if it is divisible by 4, but not divisible by 100. for example, 1992 and 2008 are divisible by 4, but not by 100. a year that is divisible by 100 is a leap year if it is also divisible by 400. for example, 1600 and 2000 are divisible by 400. however, 1800 is not a leap year because 1800 is not divisible by 400.
Answers: 3
question
Computers and Technology, 23.06.2019 22:20
What is a programming method that provides for interactive modules to a website?
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, 10.04.2021 01:00
question
Business, 10.04.2021 01:00
question
Mathematics, 10.04.2021 01:00
question
Mathematics, 10.04.2021 01:00
Questions on the website: 13722367