예제 #1
0
        public static void TrainersMenu()
        {
            Console.WriteLine("  1. All Trainers\n  2. Add a Trainer to a Course\n  3. Add a new Trainer\n  4. Go back");
            bool result = Int32.TryParse(Console.ReadLine(), out int choice);

            while (!result || (choice < 1 && choice > 4))
            {
                Console.Write("Wrong input! Please select from number 1 to 4\n");
                result = Int32.TryParse(Console.ReadLine(), out choice);
            }
            Console.Clear();

            switch (choice)
            {
            case 1:
                List <Trainer> trainers = tDB.GetTrainers();
                ShowLists.ShowList(trainers, "Trainers");
                break;

            case 2:
                TrainersPerCourseManager.AddTrainerInCourse();
                break;

            case 3:
                TrainerManager.AddTrainer();
                break;
            }
        }
        public static void MenouHeadMaster(int hm_id)
        {
            using (MyContext db = new MyContext())
            {
                Console.WriteLine($"\nHello {db.HeadMasters.Find(hm_id).FirstName},\n");
                while (1 == 1)
                {
                    try
                    {
                        Console.WriteLine("");
                        Console.WriteLine("1 - Add a Student");
                        Console.WriteLine("2 - Update a Student");
                        Console.WriteLine("3 - Delete a Student");
                        Console.WriteLine("4 - Add a Trainer");
                        Console.WriteLine("5 - Update a Trainer");
                        Console.WriteLine("6 - Delete a Trainer");
                        Console.WriteLine("7 - Add a Course");
                        Console.WriteLine("8 - Update a Course");
                        Console.WriteLine("9 - Delete a Course");
                        Console.WriteLine("10 - Add an Assignment");
                        Console.WriteLine("11 - Update an Assignment");
                        Console.WriteLine("12 - Delete an Assignment");
                        Console.WriteLine("13 - Add a Head-Master");
                        Console.WriteLine("14 - Delete a Head-Master");
                        Console.WriteLine("15 - Relate Courses and Students(students per courses)");
                        Console.WriteLine("16 - UN-Relate Courses and Students(students per courses)");
                        Console.WriteLine("17 - Relate Trainers and Courses(Trainers per courses)");
                        Console.WriteLine("18 - UN-Relate Trainers and Courses(Trainers per courses)");
                        Console.WriteLine("19 - Relate Assignments and Courses(Assignments per courses)");
                        Console.WriteLine("20 - UN-Relate Assignments and Courses(Assignments per courses)");
                        Console.WriteLine("21 - Relate Assignments and Students(Assignments per Students)");
                        Console.WriteLine("22 - UN-Relate Assignments and Students(Assignments per Students)");



                        Console.WriteLine("23 - Exit from the programme");
                        Console.WriteLine("Please select one of the options: ");
                        int user_chioce = Convert.ToInt32(Console.ReadLine());

                        switch (user_chioce)
                        {
                        case 1:
                            StudentsManager.AddStudent();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 2:
                            StudentsManager.UpdateStudent();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 3:
                            StudentsManager.DeleteStudent();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 4:
                            TrainerManager.AddTrainer();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 5:
                            TrainerManager.UpdateTrainer();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 6:
                            TrainerManager.DeleteTrainer();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 7:
                            CourseManager.AddCourse();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 8:
                            CourseManager.UpdateCourse();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 9:
                            CourseManager.DeleteCourse();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 10:
                            AssignmentManager.AddAssignment();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 11:
                            AssignmentManager.UpdateAssignment();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 12:
                            AssignmentManager.DeleteAssignment();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 13:
                            HeadMasterManager.AddHeadMaster();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 14:
                            HeadMasterManager.DeleteHeadMaster();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 15:
                            StudentsManager.RelateStudentsCourses();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 16:
                            StudentsManager.UNRelateStudentsCourses();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 17:
                            TrainerManager.RelateCoursesToTrainers();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 18:
                            TrainerManager.UNRelateCoursesToTrainers();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 19:
                            CourseManager.RelateAssignmentsToCourses();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 20:
                            CourseManager.UNRelateAssignmentsToCourses();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 21:
                            StudentsManager.RelateStudentsAssignments();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;

                        case 22:
                            StudentsManager.UNRelateStudentsAssignments();
                            Console.WriteLine("Press any key to continue");
                            Console.ReadKey();
                            break;


                        case 23:
                            Environment.Exit(0);
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Wrong input");
                    }
                }
            }
        }
예제 #3
0
        /* The AddTrainer() function allows the user to add an NPC trainer manually.
         * It needs the PokemonDataManager and MoveManager as arguments since it uses them to create the trainer's team. */
        public static void AddTrainer(PokemonDataManager pokemonDataManager, MoveManager moveManager)
        {
            Border("PkmnEngine Editor - New Trainer");

            /* The user is prompted to enter the Trainer's name. */
            Console.WriteLine("Enter Trainer Name (must be unique for now)");
            string name = Console.ReadLine();

            /* If the TrainerManager already contains a Trainer with the entered name, the user is prompted to ask if they want to overwrite it. */
            if (TrainerManager.Trainers.ContainsKey(name))
            {
                Console.WriteLine("Trainer with name {0} already exists. Overwrite? (y/n)", TrainerManager.Trainers[name].TrainerName);
                string choice = Console.ReadLine();

                /* If the user doesn't want to overwrite, the function returns. */
                if (choice[0] != 'y' && choice[0] != 'Y')
                {
                    return;
                }
                Console.WriteLine("Trainer will be overwritten.");
            }

            /* Otherwise, the user will then enter all the Trainer's details into the program. */
            Console.WriteLine("Enter Trainer Rank (Normal, Grunt, Elite, GymLeader, EliteFour, Champion)");
            TrainerRank rank = ParseEnum <TrainerRank>(Console.ReadLine());

            Console.WriteLine("Enter Trainer Difficulty (VeryEasy, Easy, Normal, Hard, VeryHard)");
            TrainerDifficulty difficulty = ParseEnum <TrainerDifficulty>(Console.ReadLine());

            Console.WriteLine("How many Pokemon does the trainer have? (Max 6)");
            byte pokemonCount = byte.Parse(Console.ReadLine());

            Pokemon[] pokemonTeam = new Pokemon[6];
            System.Threading.Thread.Sleep(500);

            /* After taking the Trainer information, the program then gets data about the Trainer's Pokemon team from the user.
             * The floor loop iterates through each Pokemon in the team according to the count specified by the user. */
            for (int i = 0; i < pokemonCount; i++)
            {
                Border("PkmnEngine Editor - New Trainer - Pokemon #" + (i + 1));
                Console.WriteLine("Enter ID of Pokemon species.");
                byte        id      = byte.Parse(Console.ReadLine());
                PokemonData species = pokemonDataManager.PokemonData[id];
                Console.WriteLine("Enter level of Pokemon. (1-100)");
                byte   level = byte.Parse(Console.ReadLine());
                Gender gender;
                if (species.CanHaveGender)
                {
                    Console.WriteLine("Enter gender of Pokemon (Male/Female).");
                    gender = ParseEnum <Gender>(Console.ReadLine());
                }
                else
                {
                    gender = Gender.none;
                }
                Console.WriteLine("How many moves does the Pokemon have?");
                byte   moveCount    = byte.Parse(Console.ReadLine());
                Move[] pokemonMoves = new Move[4];

                /* Similarly to the iteraton through the Pokemon team, the program also iterates through each Pokemon's moveset. */
                for (int j = 0; j < moveCount; j++)
                {
                    Console.WriteLine("Enter name of move #" + (j + 1));
                    pokemonMoves[j] = moveManager.Moves[Console.ReadLine()];
                }

                /* Each new Pokemon is constructed using the parameters passed in, and added to the pokemonTeam array. */
                Pokemon pokemon = new Pokemon(species, gender, pokemonMoves, level, rank);
                pokemonTeam[i] = pokemon;
                System.Threading.Thread.Sleep(500);
            }
            Border("PkmnEngine Editor - Add Pokemon");

            /* Finally, the user enters the Trainer dialogue (what the NPC says when you fight them). */
            Console.WriteLine("Enter the test dialogue for the trainer:");
            string dialogue = Console.ReadLine();

            /* The new Trainer is constructed and added to the TrainerManager. */
            Trainer trainer = new Trainer(name, rank, difficulty, pokemonTeam, dialogue, pokemonCount);

            TrainerManager.AddTrainer(trainer);
        }