Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, we will be creating code to be used in a video game. You will create three classes, an Armor class that will

In this assignment, we will be creating code to be used in a video game. You will create three classes, an Armor class that will contain the different properties of the armor. Another class will contain the Player properties. The final class will be used to test your Player and Armor classes.

1) Armor

a) Instance variables

- int Armor class

- int Durability

- String special properties of the armor

- String type of armor

b) Constructors

No argument

- Armor class to 0

- Durability to 0

- Special properties either to null or the empty string

- Type to null or the empty string

4 argument

- Set instance variables appropriately

c) Getters and setters

d) takeDamage

* Parameter

- Amount of damage to be absorbed by the armor

* Returns an int, the durability remaining

e) toString

- print the armor statistics

2) Player

a) Instance variables:

- String name

- String character class

- int hit points

- Armor players selected armor

b) Please create 3 constructors

* No argument set default values:

- Name Fred

- Character class Fighter

- Hit points 100

- Armor new Armor with no argument constructor

* 3 arugmentParameters

- Name

- Character class

- Hit points

- Armor should be set to a new no argument set of armor

* 4 argument

Parameters

- Name

- Character class

- Hit points

- Armor

c) Getters and setters for each

d) toString

- print the player statistics including armor. Should use the armor toString method

e) takeDamage method

* Parameter an int for the amount of damage the player is taking

* Will need to pass damage as appropriate to the Armor object

* Returns a String, either the durability of the armor remaining, the number of hit points the player has remaining or you are dead

3) GameDriver

a) Create a constant for the number of players, should be set to 2

b) This class should do all interaction with the user. No input or output in any other class.

c) A method to get the player information. This method should return an object of the Player class.

d) A method to get the armor information. This method should return an object of the Armor class.

e) Code either in the main or in a method to allow the Player to take damage. Will need to generate damage from 1 to 100 points to be used in the Player takeDamage method.

4) Create a UML diagram showing each of these classes.

Example output:

Please enter the character's name

Fred

Please enter the class for Fred

Fighter

Please enter the hitPoints for Fred

100

Please enter the type for the armor

plate mail

Please enter the armor class for plate mail

10

Please enter the durability for plate mail

100

Do you want to enter a special property for plate mail? (Y/N)

Y

Please enter the special property for plate mail

Walk on water

Do you want to enter a special property for plate mail? (Y/N)

n

Please enter the character's name

Sally

Please enter the class for Sally

Magic User

Please enter the hitPoints for Sally

60

Please enter the type for the armor

enhanced robe

Please enter the armor class for enhanced robe

40

Please enter the durability for enhanced robe

200

Do you want to enter a special property for enhanced robe? (Y/N)

Y

Please enter the special property for enhanced robe

Invisibility

Do you want to enter a special property for enhanced robe? (Y/N)

y

Please enter the special property for enhanced robe

Flight

Do you want to enter a special property for enhanced robe? (Y/N)

n

Player - name = Fred, charClass = Fighter, hitPoints = 100

Armor - type = plate mail, armorClass = 10, durability = 100, specialProperties =

Walk on water

You have 99 points of armor left

You have 71 points of armor left

You have 87 hit points left

You have 67 hit points left

You have 37 hit points left

You are dead

Player - name = Sally, charClass = Magic User, hitPoints = 60

Armor - type = enhanced robe, armorClass = 40, durability = 200, specialProperties =

Invisibility

Flight

You have 103 points of armor left

You have 59 points of armor left

You have 49 points of armor left

You have 37 hit points left

You are dead

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 C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions