Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am having issues with the attack(GameCharacter other), assist(GameCharacter other) and rest. GameCharacter Fields gold healthPoints level magic name Methods @ assist attack @ equals

image text in transcribed

I am having issues with the attack(GameCharacter other), assist(GameCharacter other) and rest.

GameCharacter Fields gold healthPoints level magic name Methods @ assist attack @ equals @ GameCharacter (-1 overload) @getGold @getHealthPoints @getlevel @getMagic @getName @hashCode rest SetName @toString Implement the class GameCharacter by accomplishing the following: Define fields (instance variables) Implement the constructor methods Implement the getter/setter methods Implement the attack(GameCharacter other) method, as follows: Generate a random number from 0 to 9 Calculate damage by multiplying the random number by "this" character's level. o Deduct the damage from the other character's health points. However, do not allow health points to go below zero. Implement the assist(GameCharacter other) method, as follows: o Generate a random number from 0 to 4 o If O, other character receives (level 5) health points, while "this" character loses (level 5) magic. If 1, other character receives (level 5) magic points, while this" character loses (level * 5) magic. If 2, other character receives (level 5) gold, while "this" character loses (level 5) gold. If 3, other character's level increases by 1 (add 100 to gold, health points and magic), while "this" character loses a level (decrease 100 from gold, health points and magic). o If 4, both characters' health is restored to (level 100) Implement the rest() method as you would like. Please make up your own algorithm for resting, especially since this hard to come by as a student :) Implement the toString method to create a String representation of a GameCharacter in the form: Game Character{Name="Paladin Paulding, Level=5, Health Points=500, Gold=500, Magic=500) ***Note: I used the constructor to specify level 5, which made my health, gold and magic (5*100) = 500*** . Finally, open the Main class with a public static void main(String args) method that performs the following: Create a GameCharacter to represent yourself! Create at least one more character (friend or foe). Feel free to create an array of characters to make it more interesting! o Use the helper methods (e.g. assist, attack, rest) between characters and print out the result of each interaction using System.out.printin...: with each character's name. See below for a sample interaction of myself ("Paladin Paulding") and a monster ("Monster Bug", as in coding bug). GameCharacter Fields gold healthPoints level magic name Methods @ assist attack @ equals @ GameCharacter (-1 overload) @getGold @getHealthPoints @getlevel @getMagic @getName @hashCode rest SetName @toString Implement the class GameCharacter by accomplishing the following: Define fields (instance variables) Implement the constructor methods Implement the getter/setter methods Implement the attack(GameCharacter other) method, as follows: Generate a random number from 0 to 9 Calculate damage by multiplying the random number by "this" character's level. o Deduct the damage from the other character's health points. However, do not allow health points to go below zero. Implement the assist(GameCharacter other) method, as follows: o Generate a random number from 0 to 4 o If O, other character receives (level 5) health points, while "this" character loses (level 5) magic. If 1, other character receives (level 5) magic points, while this" character loses (level * 5) magic. If 2, other character receives (level 5) gold, while "this" character loses (level 5) gold. If 3, other character's level increases by 1 (add 100 to gold, health points and magic), while "this" character loses a level (decrease 100 from gold, health points and magic). o If 4, both characters' health is restored to (level 100) Implement the rest() method as you would like. Please make up your own algorithm for resting, especially since this hard to come by as a student :) Implement the toString method to create a String representation of a GameCharacter in the form: Game Character{Name="Paladin Paulding, Level=5, Health Points=500, Gold=500, Magic=500) ***Note: I used the constructor to specify level 5, which made my health, gold and magic (5*100) = 500*** . Finally, open the Main class with a public static void main(String args) method that performs the following: Create a GameCharacter to represent yourself! Create at least one more character (friend or foe). Feel free to create an array of characters to make it more interesting! o Use the helper methods (e.g. assist, attack, rest) between characters and print out the result of each interaction using System.out.printin...: with each character's name. See below for a sample interaction of myself ("Paladin Paulding") and a monster ("Monster Bug", as in coding bug)

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_2

Step: 3

blur-text-image_3

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago