Question: Lets create a program where you can own pets that have a super power. A pet can have up to three attack moves, and each

Let’s create a program where you can own pets that have a super power. A pet can have up to three attack moves, and each move has a limited number of times you can use and how powerful each move is. A pet has a maximum health of 100, but decreases based on the attack used against them. 

Create two classes: 

A class for AttackMove where your fields are the following: number of

These two class templates should have getters and setters for the fields. 

Create another class called Game with a main method. This is where you will create the opponent pet and your pet objects. Have the pet attack each other one at a time (a turn based system) until one of the pets' health reaches 0. The pets should use all three attack moves during the game. 

If you don’t want to hardcode when to use each attack, you can use the following code to generate a random number between 1~3: 

times you can use this move how many health points the enemy

Make sure to have the import at the beginning of the file, before we declare our class. 

If the random number is 1, then use attack 1. If it’s 2, then use attack 2. If it’s 3, then use attack 3. 

The Game class is really free for all, so you can do whatever you want with it!

A class for AttackMove where your fields are the following: number of times you can use this move how many health points the enemy loses when this move is used o A method that decreases the number of times the attack can be used when you actually use it A class for the Pet health meter with maximum of 100 points Three attack moves A method that decreases the health A method that uses the attack on the enemy Some things to consider: Health cannot be less than 0 You can no longer use the attack when you've maximized the number of times you can use it.

Step by Step Solution

3.44 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To create this pet simulation game in Java well start by defining the AttackMove and Pet classes with the required fields constructor getters and sett... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction Java Program Questions!