Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Java Code. This is a Design Exercise. You will need to make classes that could be used to stage a battle as described below. You

Java Code. This is a Design Exercise. You will need to make classes that could be used to stage a battle as described below.

You have been tasked to create a number of items that can be used in an online game. All items can be used on a game character who will have a name, a number of health-points and a bag to hold the items.

Here are examples of items that can be made:

Item type of item effectOnHealth other info
Widow's Cloak Armor +15
Gladiator's Shield Armor +8
Rusty Knife Weapon -3
Protection Spell Spell 1 has magic words that can be read
Note from Zelda Letter 0 says "Beware of the Witch"

Here are examples of characters that can be made:

name health points
Godwin 30
Marilyn 40

All items can be added to any character's bag and also used on any character. (For instance the Rusty Knife could be used on a character to lower their health by 3 points.)

Armor and weapons can be equipped (worn) and removed. Spells can also be equipped (memorized) which casts a glow around the character and removed (forgotten) which removes the glow. In the future, any time a character equips or removes any item, their appearance will be altered. These methods -- for now -- can just have a body which says either "equipping" or "removing."

Both spells and letters have some text that could be read. Whenever a spell or letter is used, the text will also be read (displayed). However these items can be read independently from their use on a character.

Build these items using good interface and abstract class design as appropriate. Set the toString() method of the Character class to return a character's name and current health. You should have a good object oriented structure and good method signatures.

To illustrate this, in a driver class, two characters, Godwin and Marilyn are created. They begin by having items added to their bags (both Godwin and Marilyn get a copy of the Note from Zelda). Then the items they have are used on themselves or one another as follows:

This is a sample of how a Driver could work, staging a battle between the defensive Godwin and the offensive Marilyn.

- The Protection Spell is used on Godwin (by Godwin) - The Rusty Knife is used on Godwin (by Marilyn) - The Gladiator's Shield is used on Godwin (by Godwin) - The Rusty Knife is used on Godwin (by Marilyn)

The Driver output could look something like this:

** Godwin and Marilyn add items to their bags. Note from Zelda added to Godwin (30) Note from Zelda added to Marilyn (40) Protection Spell added to Godwin (30) Widow's Cloak added to Marilyn (40) Gladiator's Shield added to Godwin (30) Rusty Knife added to Marilyn (40)

** Godwin and Marilyn battle Protection Spell used on Godwin (31) Reading Spell,'Goddess of the day and night, protect me with all your might' Rusty Knife used on Godwin (28) Gladiator's Shield used on Godwin (36) Rusty Knife used on Godwin (33)

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

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students explore these related Databases questions