In this exercise you're playing a role-playing game named "Wizard and Warriors," which allows you to play as either a Wizard or a Warrior.
There are different rules for Warriors and Wizards to determine how much damage points they deal.
For a Warrior, these are the rules:
- Deal 6 points of damage if the character they are attacking is not vulnerable
- Deal 10 points of damage if the character they are attacking is vulnerable
For a Wizard, these are the rules:
- Deal 12 points of damage if the Wizard prepared a spell in advanced
- Deal 3 points of damage if the Wizard did not prepare a spell in advance
In general, characters are never vulnerable. However, Wizards are vulnerable if they haven't prepared a spell.
You have six tasks that work with Warriors and Wizard characters.
Override the ToString()
method on the Character
class to return a description of the character, formatted as "Character is a <CHARACTER_TYPE>"
.
var warrior = new Warrior();
warrior.ToString();
// => "Character is a Warrior"
Ensure that the Character.Vulnerable()
method always returns false
.
var warrior = new Warrior();
warrior.Vulnerable();
// => false
Implement the Wizard.PrepareSpell()
method to allow a Wizard to prepare a spell in advance.
var wizard = new Wizard();
wizard.PrepareSpell();
Ensure that the Vulnerable()
method returns true
if the wizard did not prepare a spell; otherwise, return false
.
var wizard = new Wizard();
wizard.Vulnerable();
// => true
Implement the Wizard.DamagePoints()
method to return the damage points dealt: 12 damage points when a spell has been prepared, 3 damage points when not.
var wizard = new Wizard();
var warrior = new Warrior();
wizard.PrepareSpell();
wizard.DamagePoints(warrior);
// => 12
Implement the Warrior.DamagePoints()
method to return the damage points dealt: 10 damage points when the target is vulnerable, 6 damage points when not.
var warrior = new Warrior();
var wizard = new Wizard();
warrior.DamagePoints(wizard);
// => 10