//public event BeepSoundHandler Beep; /// <summary> /// The function starts the program randomly without end, until the user presses any key. /// </summary> public static void Start() { Screen_Saver screen_Saver = new Screen_Saver(); while (!Console.KeyAvailable) { Square square = new Square(); Rectangle rectangle = new Rectangle(); Circle circle = new Circle(); VerticalLine verticalLine = new VerticalLine(); HorizontalLine horizontalLine = new HorizontalLine(); Random random = new Random(); int RandClass = 0; RandClass = random.Next(1, 5); switch (RandClass) { case 1: square.InitWithRandomValues(); screen_Saver.CallBack(square.shapePositionOnScreen_X, square.shapePositionOnScreen_Y); square.GetArea(); square.GetPerimeter(); square.Draw(); Thread.Sleep(1200); Console.WriteLine(); Console.SetCursorPosition(0, 0); square.ShowDetails(); Thread.Sleep(2000); break; case 2: rectangle.InitWithRandomValues(); screen_Saver.CallBack(rectangle.shapePositionOnScreen_X, rectangle.shapePositionOnScreen_Y); rectangle.GetArea(); rectangle.GetPerimeter(); rectangle.Draw(); Thread.Sleep(1200); Console.WriteLine(); Console.SetCursorPosition(0, 0); rectangle.ShowDetails(); Thread.Sleep(2000); break; case 3: circle.InitWithRandomValues(); screen_Saver.CallBack(circle.shapePositionOnScreen_X, circle.shapePositionOnScreen_Y); circle.GetArea(); circle.GetPerimeter(); circle.Draw(); Thread.Sleep(1200); Console.WriteLine(); Console.SetCursorPosition(0, 0); circle.ShowDetails(); Thread.Sleep(2000); break; case 4: verticalLine.InitWithRandomValues(); screen_Saver.CallBack(verticalLine.shapePositionOnScreen_X, verticalLine.shapePositionOnScreen_Y); verticalLine.GetArea(); verticalLine.GetPerimeter(); verticalLine.Draw(); Thread.Sleep(1200); Console.WriteLine(); Console.SetCursorPosition(0, 0); verticalLine.ShowDetails(); Thread.Sleep(2000); break; case 5: horizontalLine.InitWithRandomValues(); screen_Saver.CallBack(horizontalLine.shapePositionOnScreen_X, horizontalLine.shapePositionOnScreen_Y); horizontalLine.GetArea(); horizontalLine.GetPerimeter(); horizontalLine.Draw(); Thread.Sleep(1200); Console.WriteLine(); Console.SetCursorPosition(0, 0); horizontalLine.ShowDetails(); Thread.Sleep(2000); break; } Console.Clear(); } }
static void Main(string[] args) { // Call the screen saver class to start program with "start()" function. Screen_Saver.Start(); }