static void Main(string[] args) { IWeapon weapon; Character MikeA = new Character(); while (true) { Console.WriteLine("1 s, 2 a , 3 c"); string input = Console.ReadLine(); switch (input) { case "1": weapon = new Sword(); break; case "2": weapon = new Axe(); break; case "3": weapon = new Club(); break; default: weapon = new Null(); break; } MikeA.SetWeapon(weapon); MikeA.Attack(); } }
static void Main(string[] args) { // Change to your number of menuitems. const int maxMenuItems = 3; int selector = 0; bool good = false; while (selector != maxMenuItems) { Console.Clear(); DrawTitle(); DrawMenu(maxMenuItems); good = int.TryParse(Console.ReadLine(), out selector); if (good) { switch (selector) { case 1: HeroClass heroClass = new HeroClass("Choose your class then choose your path...."); heroClass.ClassPick(); break; case 2: HeroBag heroBag = new HeroBag("See the spoils of war!!!.."); Sword sword = new Sword("Sword of Destiny"); sword.Equip(); sword.TakeDamage(20); sword.Sell(); sword.TurnIn(); Console.WriteLine(); Axe axe = new Axe("Axe of Distruction"); axe.Equip(); axe.TakeDamage(20); axe.Sell(); //add inventory IItem[] inventory = new IItem[2]; inventory[0] = sword; inventory[1] = axe; //loop through and turn in all quest items for (int i = 0; i < inventory.Length; i++) { IPartOfQuest questItem = inventory[i] as IPartOfQuest; if (questItem != null) { Console.WriteLine(); questItem.TurnIn(); } } Console.ReadKey(); break; // possibly more cases here default: if (selector != maxMenuItems) { ErrorMessage(); } break; } } else { ErrorMessage(); } Console.ReadKey(); } }