Beispiel #1
0
        static void Main(string[] args)
        {
            Homework homework1 = new Homework();
            bool     execution = true;

            while (execution == true)
            {
                string a = "";
                Console.WriteLine(@"Choose variant:
            1. Create homework.
            2. Delete homework.
            3. Show all homeworks.
            4. End programm");


                string b = Console.ReadLine();
                switch (b)
                {
                case "1":
                {
                    homework1.AddHomework(homework1);
                    break;
                }

                case "2":
                {
                    homework1.DeleteHomework(homework1);
                    break;
                }

                case "3":
                {
                    homework1.GetInfo(homework1);
                    break;
                }

                case "4":
                {
                    execution = false;
                    break;
                }

                default:
                {
                    Console.WriteLine("Please enter a suggested number");
                    break;
                }
                }
            }

            Console.ReadLine();
        }
 public void DeleteHomework(Homework homework)
 {
     try
     {
         Console.Write("Enter an index of homework :");
         int input = Convert.ToInt32(Console.ReadLine());
         if (homework.listOfHomeworks != null)
         {
             homework.listOfHomeworks.RemoveAt(input);
         }
         else
         {
             Console.WriteLine("There is no homeworks");
         }
     }
     catch (Exception)
     {
         Console.WriteLine("Enter a number of homework which y wanna delete");
     }
 }
 public void AddHomework(Homework homework)
 {
     Console.WriteLine("Enter the number of homeworks that you wanna add");
     try
     {
         int input = Convert.ToInt32(Console.ReadLine());
         for (int i = 0; i < input; i++)
         {
             Console.Write("Subject: ");
             string subject = Console.ReadLine();
             Console.Write("Objective: ");
             string   objective = Console.ReadLine();
             Homework goal      = new Homework(subject, objective, DateTime.Now.DayOfWeek);
             homework.listOfHomeworks.Add(goal);
         }
     }
     catch (Exception)
     {
         Console.WriteLine("Please enter a number");
     }
 }