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 04:31
Selling a product through an electronic medium is
Answers: 1
question
Computers and Technology, 23.06.2019 19:50
Which feature is selected to practice and save the timing of a presentation
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
The ieee 802.11: defines standards for wireless local area network (wlan) communication protocols. identifies various computers or devices connected to a network. verifies any resource attached to another computer on a network that is different from the computer to which the user is logged on. connects multiple local area networks (lans) and wide area networks (wans).
Answers: 2
question
Computers and Technology, 24.06.2019 20:00
Write c++programs for the following problem: let the user enter two numbers and display which is greater. !
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
History, 12.04.2020 00:13
question
Mathematics, 12.04.2020 00:13
question
Social Studies, 12.04.2020 00:13
question
Mathematics, 12.04.2020 00:13
Questions on the website: 13722367