Last active
January 27, 2020 23:33
-
-
Save GarethOates/c8045890cd6e483850c66b0ad3b476a9 to your computer and use it in GitHub Desktop.
Decorator Pattern Output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Collections.Generic; | |
namespace MagicTheProgramming | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Creating a new Creature"); | |
ICreature creature = new Creature("Nyxborn Courser", 2, 4); | |
Console.WriteLine($"Name: {creature.Name}"); | |
Console.WriteLine($"Base Power: {creature.Power}"); | |
Console.WriteLine($"Base Toughness: {creature.Toughness}"); | |
Console.WriteLine("Equipping a Sword to the creature.."); | |
creature = new Sword(creature); | |
getStats(creature); | |
Console.WriteLine("Equipping a Shield..."); | |
Console.WriteLine("Currently Equipped: Sword and Shield"); | |
creature = new Shield(creature); | |
getStats(creature); | |
Console.WriteLine("Equipping a Helmet..."); | |
Console.WriteLine("Currently Equipped: Sword, Shield and Helmet"); | |
creature = new Helmet(creature); | |
getStats(creature); | |
Console.WriteLine("Equipping Variable Weapon"); | |
creature = new Weapon(creature, 5, 10); | |
getStats(creature); | |
Console.ReadLine(); | |
} | |
private static void getStats(ICreature creature) | |
{ | |
Console.WriteLine($"New Power: {creature.Power}"); | |
Console.WriteLine($"New Toughness: {creature.Toughness}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment