static void UseFigure3() { int length = new Random().Next(64); if (length % 2 != 0) { Square2 square = new Square2(Convert.ToUInt64(length)); square.Draw(); Console.WriteLine(square.GetType().ToString()); } if (length % 2 == 0) { Line2 line = new Line2(Convert.ToUInt64(length)); line.Draw(); Console.WriteLine(line.GetType().ToString()); } Console.WriteLine(); }
static void UseFigure2() { string key; string readline; ulong length = 0; do { Console.WriteLine("Which figure would You like do draw?"); Console.WriteLine("Line (l) or square (s)"); key = Console.ReadLine().ToString(); } while (!(key.ToLower() == "s" || key.ToLower() == "l")); if (key == "s") { do { Console.WriteLine("Please, set length of square's side."); readline = Console.ReadLine(); try { length = Convert.ToUInt64(readline); } catch (ArgumentNullException) { Console.WriteLine("You hadn't set proper length"); } catch (ArgumentException) { Console.WriteLine("You hadn't set proper length"); } catch (FormatException) { Console.WriteLine("You hadn't set proper length"); } } while (length == 0); Square2 square = new Square2(length); square.Draw(); } if (key == "l") { do { Console.WriteLine("Please, set length of line."); readline = Console.ReadLine(); try { length = Convert.ToUInt64(readline); } catch (ArgumentNullException) { Console.WriteLine("You hadn't set proper length"); } catch (ArgumentException) { Console.WriteLine("You hadn't set proper length"); } catch (FormatException) { Console.WriteLine("You hadn't set proper length"); } } while (length == 0); Line2 line = new Line2(length); line.Draw(); } Console.WriteLine(); }