Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1: Battle Game (50 points) For this question, you will write a number of classes to create a battle game between a player and

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Question 1: Battle Game (50 points) For this question, you will write a number of classes to create a battle game between a player and a monster. Your code for this question will go in multiple .java files we strongly recommend that you complete all the warm-up questions before starting this problem Note that in addition to the required methods below, you are free to add as many other private methods as you want (a) Character Class character .java represents a character in our battle game. The monster and the player will both be instances of the Character class, each with their own attributes e Character class should contain the following (private) attributes: A String name A double attack value A double maximum health value A double current health value A int number of wins in the battle game Here are the required public methods for this class. Note that you will also have to add getters and setters for the instance attributes as needed. 1) A constructor The constructor for the character class takes one string, two doubles and one int as input. These parameters represent the name, attack value, maximum health, and number of wins in the battle game for the character, in that order. Note that the current health of a new character is the same as the maximum health 2) The toString method This method returns a string consisting of the character's name and current health. Format the String in any way you want. This method will be very handy for debugging your code, and will be used during the battle game to keep track of the health of each character 3) calcAttack method This method calculates how much attack damage one character does in a battle. The calculation is as follows: Take the character's attack value and multiply it by a random value between 0.3 (inclusive) and 0.7 (exclusive). Return this value as a double. Use the Random class to generate the random numbers, and do not use a seed 4) take Damage method In this method, we take the damage done to this character as a double parameter, and then we subtract this value from the character's current health. This method does not return anything. 5) increasewins method This method will increase the number of wins by the character by one, and does not return anything. This method will be called when the character wins the battle game. Question 1: Battle Game (50 points) For this question, you will write a number of classes to create a battle game between a player and a monster. Your code for this question will go in multiple .java files we strongly recommend that you complete all the warm-up questions before starting this problem Note that in addition to the required methods below, you are free to add as many other private methods as you want (a) Character Class character .java represents a character in our battle game. The monster and the player will both be instances of the Character class, each with their own attributes e Character class should contain the following (private) attributes: A String name A double attack value A double maximum health value A double current health value A int number of wins in the battle game Here are the required public methods for this class. Note that you will also have to add getters and setters for the instance attributes as needed. 1) A constructor The constructor for the character class takes one string, two doubles and one int as input. These parameters represent the name, attack value, maximum health, and number of wins in the battle game for the character, in that order. Note that the current health of a new character is the same as the maximum health 2) The toString method This method returns a string consisting of the character's name and current health. Format the String in any way you want. This method will be very handy for debugging your code, and will be used during the battle game to keep track of the health of each character 3) calcAttack method This method calculates how much attack damage one character does in a battle. The calculation is as follows: Take the character's attack value and multiply it by a random value between 0.3 (inclusive) and 0.7 (exclusive). Return this value as a double. Use the Random class to generate the random numbers, and do not use a seed 4) take Damage method In this method, we take the damage done to this character as a double parameter, and then we subtract this value from the character's current health. This method does not return anything. 5) increasewins method This method will increase the number of wins by the character by one, and does not return anything. This method will be called when the character wins the battle game

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago