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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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