Description
You’re a muggle programmer at Hogwarts and you are a big fan of the Duelling Club. As a fan, you enjoy betting and predicting the outcome of the duels. Dumbledore asks you to create a duel simulator to predict the winner of a matchup and to bet appropriately! Using some of your own coding “magic”, you decide to create a class hierarchy that represents the wizards around you.
Solution Description
For this assignment, create files with the following names:
- java
- java
- java
- java
Please make sure to use descriptive variables and javadocs as we will be manually grading most of this assignment. You don’t have to make getters and setters for all variables, just where you think is needed!
You must use all of the best practices that we have learned in class.
Wizard Class:
Description:
- A wizard has a name, health, max health, attack power, favorite color, and spell book.
- We can create a wizard if we know their name, favorite color, max health, attack power, and spell book.
- If we don’t know their max health, let it be 25.
- All wizards have a spell book, and the default spell book has only one spell in it:
∗ Wingardium Leviosa: 0 attack power
- Wizards’ health should be at max when they are created!
Functionality:
- Wizards can cast spells.
- A wizard will randomly choose one spell from their spell book.
- When you print a wizard, we get an output:
- “[name] wishes to join the [color] house at Hogwarts! They have [current health] health points and [attack power of wizard] attack power.”
- Two wizards should be able to duel each other. Because they are having a Wizard’s duel, this method should be called on the Wizard class, not something an individual wizard does.
- The duel continues until one of the wizards’ health falls to 0.
∗ Wizards will deal damage to their opponent.
- The amount of damage is attack power of wizard + attack power of spell
∗ Each round before the attack phase, There is a 20% chance that the wizard with less health will gain 3 health.
- Print “[name] drinks an invigoration potion and restores 3 health! [name] now has [health] health.”
- Wizard’s health should not be able to go above max health.
- If the two wizards have equal health, the potion is not drunken.
∗ After taking the potion, the wizard with less health should attack first, then the other wizard attacks back.
- If a potion is drunk, check wizard health again. The wizard with the least amount of health should always attack first. This means the wizard who takes the potion may be different from the wizard who attacks first.
- If the two wizards have equal health, you can choose the wizard that attacks first.
∗ When each wizard attacks,
- Print “[name] casts [spell name] and deals [damage] damage. [other name] now has [other wizard health] health.” ∗ Health cannot fall below 0 at any point.
- If a wizard’s health falls to 0, print “[name] falls to the ground. [other name] wins the duel!”
∗ After the duel, restore both wizards’ health to their max health.
- Wizards can interact with another wizard.
- prints “[name]: Hey [other name], let’s be friends!” – Duel will commence between two wizards.
- Correctly decides if two wizards are equal based on: name, health, attack power, color, and spell book.
Gryffindor Class:
Description:
- Gryffindors are also wizards, so they should be able to have/do everything a normal wizard can do!
- We can create a Gryffindor wizard if we know their name.
- Gryffindors focus on resilience and therefore have more health.
- Max health is a random number between 25 to 30 (inclusive).
- Base attacking power is a random number between 4 to 6 (inclusive).
- Gryffindors love the color scarlet.
- Gryffindors have a special spell book given by Dumbledore and can cast the following spells:
- Expecto Patronum: 3 attack power
- Expelliarmus: 2 attack power
- Ridikkulus: 1 attack power
- Wingardium Leviosa: 0 attack power
Functionality:
- Interacts with another wizard:
- prints “[name]: Hey [other name], let’s be friends!” – Duel will commence between two wizards.
Slytherin Class:
Description:
- Slytherins are also wizards, so they should be able to have/do everything a normal wizard can do!
- We can create a Slytherin wizard if we know their name.
- Slytherins focus on self preservation and therefore have stronger attacking power. – Max health is a random number between 22 to 27 (inclusive).
- Base attacking power is a random number between 5 to 7 (inclusive).
- Slytherins love the color green.
- Slytherins have a special spell book with some dark arts and can cast the following spells:
- Expulso: 3 attack power
- Levicorpus: 2 attack power
- Oppugno: 1 attack power
- Flipendo: 1 attack power
- Wingardium Leviosa: 0 attack power
Functionality:
- Interacts with another wizard:
- prints “[name]: Hey [other name], let’s be friends!” – Duel will commence between two wizards.
Spell Class:
Description:
- Each spell should have a name and a damage associated with it.
- When you print a spell it will output:
- [spell name]: [damage] attack power
- Compares two spells’ name and damage and returns a boolean depending on if the spells are the same.




