Question: PART A In Part A , you will design and implement the upgrade system of an action - adventure game. Use the following class diagram
PART A
In Part A you will design and implement the upgrade system of an actionadventure game.
Use the following class diagram to implement the new Item. The player can also pick up and add
enhancements to increase the damage and durability of their weapon.
damage durability
Weapons:
Sword
Enhancements:
Iron
Gold
Diamond
Magic
energy
Food:
Bread
Ham
Pizza
Decorator Pattern
a Draw the sequence diagram for the display of the weapon stats for a sword that equips
gold, iron, iron, and magic. Assume that the player is presented with these items in
that order.
b Implement the design.
i Complete the code with the Player class with any other required
fieldsmethods and required classes of the Items hierarchy.
Starter code provided: Item interface
ii Program a simulation of your system in use. Create a driver class named
GameDriver that illustrates the upgrade system in gameplay
The game simulation starts with the player with health and no weapon sword
is null, but can be the first item the player picks up
Present random items food and enhancements to the player
An additional poison item may be presented to the player: the game
ends if the player picks it up
The player will decide if they want to use each item
Update and display the health and weapon stats as applicable
Notes:
Weapons can have unlimited enhancements and stats
Consider using JOptionPane for player input using showConfirmDialog eg
result JOptionPane.showConfirmDialognull enhancement :
pick upnull, JOptionPane.YESNOOPTION;
Observer pattern and HUDachievements from Assignment are NOT required. You
can simply print from the Player class andor driver to achieve the updates.
BE SURE TO COMMIT ALL YOUR CHANGES BEFORE MOVING ON TO PART
Adapter Pattern
Add a new feature to your system: the ability to use a Food item as a weapon! When the
player first encounters the ham, the system will give them the option to equip it as a weapon.
From there, the player can add enhancements to their new ham weapon.
This new feature will use the Adapter pattern, where the adaptee is the Food interface.
a Add a new class FoodAdapter to the class diagram that implements the methods of
the Weapon class with the intent for the food item ham to be used as a concrete
weapon you can simply draw a segment of the class diagram, that represents this
pattern
b Add the sequence diagram for when the player first picks up a ham, and then chooses
to use it as a weapon see d below and sample output
c Implement your new feature.
Add the applicable methods to the FoodAdapter where the food items
damage corresponds to the foods energy, and the durability is
In the Player class, include the new field eg hamWeapon
of type Weapon, and any applicable methods required for your simulation.
d Update the game simulation to include your new feature. When the player is
presented with a special item, they are given the choice to add it as a new weapon.
After it is assigned as the SpecialWeapon, the player can choose to upgrade it with
enhancements found in the world. After equipping it as a weapon, any other special
item eg ham found in the world will only be consumed for energy.
Notes:
Consider using JOptionPane for choosing between sword and ham with
showOptionDialog eg
String buttons sword "ham";
JOptionPane.showOptionDialognull "Select the weapon to
enhance: null,JOptionPane.DEFAULTOPTION,
JOptionPane.INFORMATIONMESSAGE, null, buttons, buttons;
Test to make sure that the getDescription provides a meaningful string of the layers of
decorators eg magic, iron, sword
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
