Answered step by step
Verified Expert Solution
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
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 a 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. The 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 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 a 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. The 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started