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

  The arraylist class

Create a class to represent a term in an algebraic expression. As defined here, a term consists of an integer coefficient and a nonnegative integer exponent.  E.g.

  Introduction identifying the purpose of the paper

After reading the information presented in Chapter 2 of your course textbook and performing web-based research as supported by three or more references, write a three-page (minimum) paper plus a References page (final page of your submission) that..

  What price would you pay for cash flows

What price would you pay for these cash flows? What total wealth do you expect after 2.5 years if you sell the rights to the remaining cash flows?

  Determine the monthly payment for a loan

Write a program to determine the monthly payment for a loan where the annual interest rate, the amount of the loan, and the number of years are entered as input.

  Provincial manager for a financial services firm

As the Provincial Manager for a financial services firm, you are well regarded within your company and especially by many of the 82 employees

  What is meant by fundamentals vs application mass

a) What is meant by "fundamentals vs. application mass". b) What is meant by timelessness of a fundamental truth c) What part of a system constantly evolves and d) What are the pre-requisites for a..

  Determine the corresponding poly phase filter

Also, determine the corresponding poly phase filter structure for implementing the interpolator.

  Perform a stock valuation prior

You have been asked to perform a stock valuation prior to the annual shareholders meeting next week. The two models you've selected to value the firm are 1) the dividend discount model and 2) the discounted cash flow model. Explain why the estimat..

  Showing web page to participants in real time

Purchasing/leasing/outsourcing hardware versus purchasing/licensing software (including its multilingual versions)

  Vulnerability scanning takes place

You realize that when vulnerability scanning takes place, employees need to know what the expectations are for handling the findings.

  Calculate the accumulated interest

A principle of $5000 is invested at 7.5% compounded monthly for 7 years. a.) Calculate the accumulated interest at end of each year.

  Using a truth table or equivalent determine following

Using a Truth Table or equivalent determine

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