Repository link: https://github.com/CSE-116/ProblemSet-2
To submit your project, run problem.Zipper, which will create a zip file containing the
problem set, and submit it to Autolab.
For this Problem Set, you will implement the following functionality. Note that all of the methods are public and non-static.
Monster (5 points): Create an abstract class in the problem package
named Monster. This class should implement the following methods:
String and an int
representing the name and maximum health of the monster. The current health of the monster should
initially be set to the maximum amount.
Monster is created with a max health of 10, the initial health
would also be 10. The max health should never change, even if the current health does.
getName: create a method named getName which takes no parameters and returns a
String. This method should return the name of the Monster.
setName: create a method named setName which takes a single
String and returns void. This method should set the name of the
Monster to the input value.
getHP: create a method named getHP which takes no parameters and returns an
int. This method should return the current health of the Monster.
setHP: create a method named setHP which takes a single int and
returns void. This method should set the current health of the Monster to the
input value.
getMaxHP: create a method named getMaxHP which takes no parameters and returns
an int. This method should return the maximum health of the Monster.
attack: create an abstract method named attack which takes a
reference
to a Monster object and returns void.
Skeleton (5 points): Create a class in the problem package named Skeleton. This
class should extend the Monster class described above. This class should implement the following
methods:
String and two ints
representing the name, maximum health, and damage of the skeleton, respectively.
getDamage: create a method named getDamage which takes no parameters and
returns an int. This method should return the damage value of the Skeleton.
setDamage: create a method named setDamage which takes a single
int and returns void. This method should set the damage value of the
Skeleton to the input value.
reanimate: create a method named reanimate which takes no parameters and
returns void. If the Skeleton's health is less than or equal to 0, it should
set it to the
maximum health of that object. If its health is greater than 0, it should do nothing.
attack: override the abstract method of the same name from the Monster class.
It should take a reference to a Monster object and return void. This method
should decrease
the health of the Monster parameter by the damage of that Skeleton.
Skeleton was created with a damage of 5, and a
Monster with a health of 8 was passed in, its health would be decreased to 3.
Skeleton was created with a damage of 5, and a Monster with a health
of 1 was passed in, its health would be decreased to -4.
Creeper (5 points): Create a class in the problem package named Creeper. This
class should extend the Monster class described above. This class should implement the following
methods:
attack: override the abstract method of the same name from the Monster class.
It should take a reference to a Monster object and return void. This method
should set the hp of the monster and the creeper to 0.
StringList (5 points): Create a class in the problem package named StringList.
This class will contain methods for using and manipulating LinkedListNodes of Strings.
You must use the LinkedListNode class provided, which can be found in
problem.datastructures. This class should implement the following methods:
getList: create a method named getList which takes no parameters and returns a
LinkedListNode of Strings. This method should return the entire linked list of
strings.
setList: create a method named setList which takes a
LinkedListNode of Strings as a parameter and returns void. This
method should
set the linked list of strings to the input value.
addElement: create a method named addElement which takes a single
String as a parameter and returns void. This method should append the input
String to the end of the linked list.
getMidpoint (10 points): create a method in the StringList class named getMidpoint which takes no parameters and
returns a String. This method should return the value at the middle index of the linked
list.
String.
deleteElement (10 points): create a method in the StringList class named deleteElement which takes a
String as a parameter and returns void. This method should remove the first
occurrence of
the input String from the list.
Strings for equality, always use the .equals method. Do not compare them using ==.
zipperMerge (10 points): create a method in the StringList class named zipperMerge which takes a
StringList as a parameter and returns void. This method should zipper merge the parameter list
with this list. The zipper should start with this list and merge the two lists by alternating values from the lists. The list from the parameter should remain unchanged.