public static void Main(string[] args) { shape s = null; int userinput; do { Console.WriteLine("choose an option to draw shapes"); Console.WriteLine("1: circle"); Console.WriteLine("2: triangle"); Console.WriteLine("3: rectangle"); Console.WriteLine("4: square"); Console.WriteLine("enter your input"); userinput = Convert.ToInt32(Console.ReadLine()); switch (userinput) { case 1: s = new circle(); break; case 2: s = new triangle(); break; case 3: s = new rectangle(); break; case 4: s = new square(); break; default: Console.WriteLine("wrong"); Environment.Exit(0); break; } s.Draw(); }while (userinput >= 1 && userinput <= 5); /* var drawobj = new List<shape> * { * new circle(), * new triangle(), * new rectangle(), * new square(), * }; * * foreach(shape s in drawobj) * { * s.Draw(); * }*/ Console.ReadLine(); }
public static void Main(string[] args) { shape s = null; int ui; do { Console.WriteLine("enter the option to choose"); Console.WriteLine("1:circle 2:triangle 3:rectangle 4:square 5:exit"); ui = Convert.ToInt32(Console.ReadLine()); switch (ui) { case 1: s = new circle(); break; case 2: s = new triangle(); break; case 3: s = new rectangle(); break; case 4: s = new square(); break; case 5: break; default: Console.WriteLine("wrong option"); break; } s.draw(); } while(ui >= 1 && ui <= 5); /* var drawobjects = new List<shape> * { * new circle(), * new triangle(), * new rectangle(), * new square() * }; * foreach(shape s in drawobjects) * { * s.draw(); * }*/ Console.ReadLine(); }