Get Instant Help From 5000+ Experts For
question

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing:Proofread your work by experts and improve grade at Lowest cost

And Improve Your Grades
myassignmenthelp.com
loader
Phone no. Missing!

Enter phone no. to receive critical updates and urgent messages !

Attach file

Error goes here

Files Missing!

Please upload all relevant files for quick & complete assistance.

Guaranteed Higher Grade!
Free Quote
wave
Creating and Managing a Game Object in Java
Answered

Task

•Three fields, title, objective (of the game) and cost In Pence (in pence of each download);


•A constructor, which allows you to pass arguments to initialise these three attributes in the order specified above;


•Accessor and mutator methods for each field.

•Write a method download() which allows a user to "download a copy of the game". Since this is only a model, at the moment, all we do is output a message which congratulates the user on their download and reminds them of the cost. It also updates the value of a new field number Of Downloads;


•Add two fields which


1. Store the name of the player with the best score called best Score Name;


2. Store the score itself called best Score which initially is set to zero.


•Write a method check Score() which, when given a player's score and name in that order, checks to see whether that particular score is the best score to date and if so, replaces the best score with this new score and also replaces the relevant best score name.


•Write a print Report() method which outputs the title, the objective of the game, the cost of each download, the number of downloads, the best score and the name of the person who has the best score. Each piece of information must be stored on a separate line and in the order given below (though, of course, replacing these values with your own):

Title : Revenge of the Killer Zombies


Objective : To thrill


Download cost : 75


Number of downloads to date : 6784


Best score to date : 20000


Player with best score : Prof Linge


Note that any number printed above should be simply output as a whole number without any additional symbols or formatting.

So far, testing of the program has been quite repetitive and always starts from scratch. However, we could introduce a default constructor with the field values hard-coded. This means that when we create our object and then call this default constructor, it is as though our object has been in existence for some time. This will help particularly with your testing. Introduce a second, default constructor now.

•Write a method calculate Earnings() which calculates how much money this particular game has earnt its writer;


•Do not add an extra field to keep track of the running earnings total.


•Now amend your print Report() method to include this new information i.e. the earnings to date, on a separate last line exactly in the order below

Title : Revenge of the Killer Zombies


Objective : To thrill


Download cost : 75


Number of downloads to date : 6784


Best score to date : 20000


Player with best score : Prof Linge


Earnings to date : 508800


Note that any number printed above should be simply output as a whole number without any additional symbols or formatting.

Introduce a new class, called Manager, to the project. Its purpose is to represent the manager of the game. It should have


•Two fields surname and manager ID (where both are string variables);


•A suitable constructor and accessor methods.


Next, add a new field game Manager, of type Manager, to the Game class. Modify Game's constructor by giving it an additional last parameter so that the new field can be initialised when the constructor is called.

To test your code


•Create a Manager object;


•Create a Game object, and pass to its constructor


•Values for the three fields (as usual);


•The identifier for the Manager object e.g. manager1 (or, more easily, click on the Manager object on the Object Bench);


•Inspect the Game object using the Object Inspector. If you double click on the game Manager field, a new Object Inspector window will open and you should see the fields of the Manager object you created -- this will confirm that your code for Step 4 is working correctly.

Now amend the print Report() method of the Game class so that it also outputs the surname of the manager on a separate last line exactly in the order below


Title : Revenge of the Killer Zombies


Objective : To thrill


Download cost : 75


Number of downloads to date : 6784


Best score to date : 20000


Player with best score : Prof Linge


Earnings to date : 508800


Manager’s name : Bailey

support
close