Computer to compete against other to correctly guess

Assignment Help Basic Computer Science
Reference no: EM131935835

The aim of Gue55ing Game is for a person and the computer to compete against other to correctly guess a hidden number. 

A game consists of four rounds. For each round a number between 1 and 100 (inclusive) is randomly generated and the players (person and computer) take turns to guess the number. The round ends when the correct guess is given or each player has had three guesses. 

If a player guesses the number correctly then they are awarded points according to how many attempts were taken to guess the number. If the round ends without either player guessing correctly then the points are awarded to each player according to how close they were to the hidden number. 

At the end of the four rounds the player with the highest cumulative score wins the game. 

Your program should consist of at least three classes: Player, Game and RandomNumber. 

Player class 

The Player class will specify the attributes and behaviours of a player. An object of the Player class will have the following fields (at least): 

Name - the name of the player. 

Score - the cumulative game score 

Guesses - the last number guessed for the current round 

The data type of each field must be chosen carefully and you must be able to justify the choice of the data type of the fields. You may want to include comments in the class to state the assumption made. The class must also have a default constructor and a non-default constructor that accepts a value for the name of the player. 

The Player class should also have appropriate accessor and mutator methods for its fields. You should not allow an object of class Player to be set to an invalid state. There should be no input from the terminal or output to the screen. A Player object should also be able to return its state in the form of a String. 

Game class 

The Game class will be in the same BlueJ project that contains your Player class. The Game class will manage the playing of a game. It will have the following fields (at least): 

Player1 (an object of type Player) 

Player2 (an object of type Player) 

Note that one of these players will be the computer. 

The Game class will have methods to manage the playing of the game. These should include (at least) the following behaviours: 

    • Display a welcome message on the screen.
  • Request the player to enter their name. 
  • Request the player to enter a number. 
  • Compare the number entered by a player with the hidden number. 
  • Display the result of the attempt at guessing the number. 
  • Display the result for the end of a round (including the value of the hidden number). 
  • Display the game result. 

RandomNumber class 

An object of the RandomNumber class will generate a random number from 1 to a maximum value specified.

Reference no: EM131935835

Questions Cloud

Calculate the accrued interest of the bonds : Assume that you bought Treasury bonds. The settlement date of the bonds is 9/30/2017, and the bonds pay coupon interests on 8/15 and 2/15 each year.
Explore options to produce infographics to hans rosling : Explore and identify the options available in Excel to produce similar infographics to Hans Rosling.
Overlap with concerns pertaining to cybercrime : Explain how issues involving security in cyberspace overlap with concerns pertaining to cybercrime.
Discuss about the discounting mirr : Assume that the Boilermaker Investment Company takes on a project that will have them heating ten buildings at Purdue University for a period of 3 years.
Computer to compete against other to correctly guess : The aim of Gue55ing Game is for a person and the computer to compete against other to correctly guess a hidden number.
Discuss about the rate of return on your firm stock : Assume that the average firm in your company's industry is expected to grow at a constant rate of 4% and that its dividend yield is 7%.
List and describe the food item : List and describe the food item, and include where it came from. Can you live without the food item you chose? Is there a local substitute available?
Important in the electronic communications : How is bandwidth defined, and why it is so important in the electronic communications?
Symptoms and medical histories into a computer : DQ 1. What pros and cons could result from patients entering their own symptoms and medical histories into a computer?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Necessary part of any business

1. It is common knowledge that employees are a necessary part of any business. Identify three (3) best practices in the user domain and suggest the control type(s) (technical or manual) that are best suited to monitor each best practice.

  Derive decision parameters for midpoint ellipse algorithm

Derive decision parameters for the midpoint ellipse algorithm assuming the start position is (rx,0) and points are to be generated along the curve path in counterclockwise order.

  Example of converting a rational exponent to a radical

In your own words, explain the relationship between rational exponents and radicals. Show an example of converting a rational exponent to a radical. For this DQ, complete the problem provided by your instructor.

  Design the state diagram for a simple controller

The lamp is turned off whenever the internal clock matches an internal register fLiteOffl that holds the time to turn the light off.

  Digital rights and intellectual property

Discussion Activity #6:  Digital Rights and Intellectual Property  Course Objective: Critically assess the digital rights management issues that exist in cyberspace. The class discusses digital rights management and its impact on cybersecurity polic..

  Provide future of mimo

What is MIMO? What's the history? What issues are addressed? What are the goals? Identify all advantages and disadvantages of MIMO.

  Compute the sum of credit hours

Under the rows compute the sum of credit hours and the sum of quality points. Somewhere on the sheet display the semester GPA computed as sum of quality points divided by the sum of credit hours.

  How many bits are used for memory addresses

How many bits are used for memory addresses

  Business process management for xyz company

Create an original essay of 3- to 5- pages, entitled "Business Process Management for XYZ Company." (Replace XYZ Company with the actual company name.) This paper should be an assessment of how you would use the components of business process desi..

  Showing the hierarchical parent-child relationships

The parent of each process on the system can be found by inspecting the PPid: line of all of the /proc/PID/status files on the system. Be careful to handle the possibility that a process's parent (and thus its /proc/PID directory) disappears durin..

  Discuss the concept of wireless signal congestion

Discuss the concept of wireless signal congestion. As the airwaves become more congested with wireless devices, those signals interfere with one another.

  Covert the subsequent decimal numbers into binary numbers

Write the results of the two numbers (in decimal) after the BIT operations and please covert the subsequent decimal numbers into binary numbers:  (using 2 bytes = 16 bits)

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd