Colored Items
The following is one possible solution to this challenge.
using System;
ColoredItem<Sword> sword = new ColoredItem<Sword>(new Sword(), ConsoleColor.Blue);
ColoredItem<Bow> bow = new ColoredItem<Bow>(new Bow(), ConsoleColor.Red);
ColoredItem<Axe> axe = new ColoredItem<Axe>(new Axe(), ConsoleColor.Green);
sword.Display();
bow.Display();
axe.Display();
public class ColoredItem<T>
{
public T Item { get; }
public ConsoleColor Color { get; }
public ColoredItem(T item, ConsoleColor color)
{
Item = item;
Color = color;
}
public void Display()
{
Console.ForegroundColor = Color;
Console.Write(Item);
}
}
public class Sword { }
public class Bow { }
public class Axe { }