Пример #1
0
        public static void WriteRoundToFile()
        {
            Round       round      = new Round();
            RoundWorker fileWorker = new RoundWorker();

            try
            {
                Console.Write("Enter X: ");
                round.Center.X = double.Parse(Console.ReadLine());
                Console.Write("Enter Y: ");
                round.Center.Y = double.Parse(Console.ReadLine());
                Console.Write("Enter Radius: ");
                round.Radius = double.Parse(Console.ReadLine());
                fileWorker.ToFile(round);

                Console.BackgroundColor = ConsoleColor.Green;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine("The file has successfully written!");
                Console.ResetColor();
            }
            catch (Exception e)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine(e.Message);
                Console.ResetColor();
            }
        }
Пример #2
0
        public static Round CreateRound(string path)
        {
            Round       round      = null;
            RoundWorker fileWorker = new RoundWorker();

            try
            {
                round = fileWorker.GetRound(path);
            }
            catch (Exception e)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine(e.Message);
                Console.ResetColor();
            }
            return(round);
        }