The Inhabitants of Old Ireland
In a small town known as Ballybeg, north of Dublin, there once lived
mystical creatures. In this town, there are three kinds of Inhabitants:
Werewolves, Fairies, and Humans.
Attributes
All Inhabitants have names that cannot change. They all have numeric
ratings for four basic attributes that describe their abilities: Strength,
Agility, Armour and Health Rating. These attributes can be raised or
lowered by one point at a time, within the range 0 to 10. The name and
basic attributes of an inhabitant are obvious and can be easily retrieved by
anyone. An Inhabitant is alive if their heath rating is greater
than 0, otherwise they are dead. An inhabitant cannot be brought back from the dead.
Every Werewolf belongs to either the “Blue Moon” or “Red Moon” pack. They are proud of their
allegiance and would never change it.
Each Werewolf has two Fairies that they consider their allies. However, the werewolves are not trusting
and can change their minds about which Fairies they align with.
A Human can be a Healer or a Hunter. A Healer is a friend of a single Werewolf and this does not change.
A healer starts with a magic rating that is randomly set between 0 and 10.
Abilities
Attack and Defense
When an Inhabitant other than a Hunter attacks, it produces a damage score equal to the average of its
strength, agility, and health. When a Hunter attacks, it does twice the normal damage.
When an Inhabitant defends itself against an attack, it will lose health points equal to the damage score
of the attack divided by its armor rating. If the damage score divided by the armor rating is less than 1,
than it will lose 1 health point.
Dead inhabitants cannot attack or defend themselves.
© Sam Scott and Karen Laurin, Mohawk College, 2021
Healing
When a Healer uses their magic, they can produce a healing score to help another Inhabitant.
The healing score is equal to their magic rating divided by 2, but the healer loses 1 point from
their magic rating. If its magic rating is 0 or less, it cannot heal. Dead Healers can’t heal.
A fairy can replenish a healer’s magic using a spell. The spell resets the healer’s magic rating
randomly to a value between 0 and 10.
The Design
Draw a UML class diagram for a set of classes to represent the inhabitants of the word described above.
Make sure to represent all instance variables, parameters, return values, and relationships between
classes. You can create your UML diagram on paper, using UMLet or draw.io. If you want to use a
different piece of software, check with your instructor first.
Use inheritance to eliminate code duplication and overriding to avoid if statements (e.g. don’t have an if
statement to check if the Inhabitant is a Hunter before reporting damage).
Use encapsulation to restrict access to the instance variables.
Include the minimum set of methods to implement the world as described above.
Include two constructors for each class: one that sets all instance variables, and one that sets just the
name (and the Werewolf friend for a Human) and fills in default parameters for everything else.
Include a toString method for every class that prints the class name, the name of the humanoid,
whether they are alive or dead, and all their ratings (health, strength, etc.). Make sure the output is easy
to read.
The Implementation
Implement the classes you designed in Java.
It would be a good idea to test each class by creating at least two instances (one for each constructor),
calling each method, and printing the results of each method to standard output. But this is not
required. For this assignment, you are developing the model but not the view.
Use automatic code generation as much as you can (“Insert Code” to create constructors, getters,
setters and toString methods).
Use the super and this keywords to eliminate code duplication wherever possible.
Check for errors in all methods (e.g. parameters out of range, null parameters, actions can’t be taken
when the Inhabitant is dead, etc.). If an error happens, print a meaningful error message to standard
output and return immediately from the method. Make sure you test the error cases.
Optional Extras
This is purely a design exercise, but maybe it could be turned into some sort of a game. For example, can
you simulate turn-based combat between a Werewolf and a Hunter? Can you make it graphical? Is there
anything else you can do to make the town of Ballybeg come to life
NOTE: This is a college-level project so DON’T use high-level programming and DON’T use any AI tool to write the code. Please read all the instructions properly write the code accordingly. Thank you!!
Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount