示例#1
0
        public Students CreateStudents()
        {
            Console.Clear();
            Console.WriteLine();
            Console.WriteLine();
            Students       std         = new Students();
            List <Courses> listCourses = new List <Courses>();

            Console.Write($" Enter fullname of student: ");
            std.Fullname = Console.ReadLine();
            bool flag = true;

            while (flag)
            {
                Console.Clear();
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine($" Select how many courses this student will be registered to: ");
                Console.WriteLine();
                Console.WriteLine(" 1) C#");
                Console.WriteLine(" 2) Java");
                Console.WriteLine(" 3) JavaScript");
                Console.WriteLine(" 4) Machine Learning");
                Console.WriteLine(" 5) Game Development");
                Console.WriteLine(" 6) Stop and return to Main Menu");
                Console.Write(" Select course to add or press 6 to stop: ");

                int.TryParse(Console.ReadLine(), out int choice);

                while (choice == 0 || choice > 6 || choice < 0)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("Please choose 1, 2, 3, 4, 5 or 6: ");
                    Console.ForegroundColor = ConsoleColor.White;
                    int.TryParse(Console.ReadLine(), out choice);
                }

                Courses cor = new Courses();
                switch (choice)
                {
                case 1:
                    cor.Name = "C#";
                    listCourses.Add(cor);
                    Console.Clear();
                    break;

                case 2:
                    cor.Name = "Java";
                    listCourses.Add(cor);
                    break;

                case 3:
                    cor.Name = "JavaScript";
                    listCourses.Add(cor);
                    break;

                case 4:
                    cor.Name = "Machine Learning";
                    listCourses.Add(cor);
                    break;

                case 5:
                    cor.Name = "Game Developement";
                    listCourses.Add(cor);
                    break;

                case 6:
                    flag = false;
                    break;
                }
            }


            CList.Add(listCourses);
            return(std);
        }
示例#2
0
        static void Main(string[] args)
        {
            List <Students> SList = new List <Students>();
            //List<Students> listStudents = new List<Students>();
            List <Courses> CList = new List <Courses>();

            Students std = new Students();
            Courses  crs = new Courses();
            //MainMenu menu = new MainMenu();
            //menu.ShowMainMenu();
            //------------------------------------------------------------------------>>>
            bool mainMenu = true;

            while (mainMenu)
            {
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.WriteLine(@"
                                         _    _      _                           _
                                        | |  | |    | |                         | |
                                        | |  | | ___| | ____ ___  _ __ ___   ___| |
                                        | |/\| |/ _ \ |/  __/ _ \| '_ ` _ \ / _ \ |
                                        \  /\  /  __/ |  (_| (_) | | | | | |  __/_|
                                         \/  \/ \___|_|\____\___/|_| |_| |_|\___(_)");
                Console.WriteLine("\n");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("1) Show Entries");
                Console.WriteLine("2) Create New");
                Console.WriteLine("3) Exit\n");
                Console.Write("Select an option: ");
                int.TryParse(Console.ReadLine(), out int mainMenuChoice);

                while (mainMenuChoice == 0 || mainMenuChoice > 3 || mainMenuChoice < 0)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("Please choose 1, 2 or 3: ");
                    Console.ForegroundColor = ConsoleColor.White;
                    int.TryParse(Console.ReadLine(), out mainMenuChoice);
                }
                switch (mainMenuChoice)
                {
                case 1:
                    Console.Clear();
                    bool thisMenu = true;
                    while (thisMenu)
                    {
                        Console.WriteLine();
                        Console.WriteLine();
                        Console.WriteLine("1) Show Students");
                        Console.WriteLine("2) Show Trainers");
                        Console.WriteLine("3) Show Courses");
                        Console.WriteLine("4) Show Assignments");
                        Console.WriteLine("5) Return To Main Menu\n");
                        Console.Write("Select an option: ");
                        int.TryParse(Console.ReadLine(), out int MenuChoice);

                        while (MenuChoice == 0 || MenuChoice > 5 || MenuChoice < 0)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Write("Please choose 1, 2, 3, 4 or 5: ");
                            Console.ForegroundColor = ConsoleColor.White;
                            int.TryParse(Console.ReadLine(), out MenuChoice);
                        }
                        if (MenuChoice == 1)
                        {
                            ShowStudents(SList, std.CList);
                            //Showstudents();
                        }
                        else if (MenuChoice == 2)
                        {
                            Trainers tr = new Trainers();
                            tr.ShowTrainers();
                        }
                        else if (MenuChoice == 3)
                        {
                            //ShowCourses();
                        }
                        else
                        {
                            Console.Clear();
                            thisMenu = false;
                        }
                    }
                    break;

                case 2:
                    Console.Clear();
                    Console.WriteLine();
                    Console.WriteLine();
                    //Students std = new Students();
                    Console.WriteLine("1) Create student");
                    Console.WriteLine("2) Create student using synthetic data");
                    Console.WriteLine("3) Return to Main Menu\n");
                    Console.Write("Select an option: ");
                    int.TryParse(Console.ReadLine(), out int menuChoice);

                    while (menuChoice == 0 || menuChoice > 3 || menuChoice < 0)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write("Please choose 1, 2 or 3: ");
                        Console.ForegroundColor = ConsoleColor.White;
                        int.TryParse(Console.ReadLine(), out menuChoice);
                    }

                    switch (menuChoice)
                    {
                    case 1:
                        //Console.Clear();
                        SList.Add(std.CreateStudents());
                        break;

                    case 2:
                        Console.Clear();
                        Console.WriteLine("Call create new method");
                        break;

                    case 3:
                        Console.Clear();
                        //ShowMainMenu();
                        break;
                    }
                    break;

                case 3:
                    System.Environment.Exit(1);
                    break;
                }
            }
        }