Esempio n. 1
0
        public static void displayOnePlanet()
        {
            Console.WriteLine("Enter a name or quit (Q):");
            string nameOfPlanet = Console.ReadLine();

            if (nameOfPlanet == "Q" || nameOfPlanet == "q")
            {
                Console.Clear();
                displayMainMenu();
            }
            Planets pFounds = planets.getPlanetByName(nameOfPlanet);

            if (pFounds.ListPlanet.Count == 0) //If any characters match with the name
            {
                Console.Clear();
                Console.WriteLine("The name doesn't match with a planet. Retry !");
                displayOnePlanet();
            }
            else
            {
                Console.Clear();
                Console.WriteLine(pFounds.ToString());
                displayBackMenu();
            }
        }
Esempio n. 2
0
        public static void displayMainMenu() //Enable to display a menu
        {
            int choice;

            Console.WriteLine("1. Display all characters\n -------------------------");
            Console.WriteLine("2. Display all planets\n -------------------------");
            Console.WriteLine("3. Display a character(with name)\n -------------------------");
            Console.WriteLine("4. Display a planet(with name)\n -------------------------");
            Console.WriteLine("5. Add a character\n -------------------------");
            Console.WriteLine("6. Add a planet\n -------------------------");
            Console.WriteLine("7. Delete a character\n -------------------------");
            Console.WriteLine("8. Delete a planet\n -------------------------");
            Console.WriteLine("Choose (1/2/3/4/5/6/7) :");

            choice = int.Parse(Console.ReadLine());

            switch (choice)
            {
            case 1:
                Console.Clear();
                Console.WriteLine(characters.ToString());
                displayBackMenu();
                break;

            case 2:
                Console.Clear();
                Console.WriteLine(planets.ToString());
                displayBackMenu();
                break;

            case 3:
                Console.Clear();
                displayOneCharacter();
                break;

            case 4:
                Console.Clear();
                displayOnePlanet();
                break;

            case 5:
                Console.Clear();
                addACharacter();
                break;

            case 6:
                Console.Clear();
                addAPlanet();
                break;

            case 7:
                Console.Clear();
                deleteACharacter();
                break;

            case 8:
                Console.Clear();
                deleteAPlanet();
                break;
            }
        }
Esempio n. 3
0
        public static void addACharacter()
        {
            Console.WriteLine("Planet or quit (Q): ");
            string planet = Console.ReadLine();

            if (planet == "Q" || planet == "q")
            {
                Console.Clear();
                displayMainMenu();
            }
            Planet  planetOfTheCharacter = new Planet();
            Planets pFounds = planets.getPlanetByName(planet);

            if (pFounds.ListPlanet.Count == 0) //If any planet match with the name
            {
                Console.Clear();
                Console.WriteLine("The name doesn't match with a character. Retry !");
                addACharacter();
            }
            else if (pFounds.ListPlanet.Count == 1)
            {
                planetOfTheCharacter = pFounds.ListPlanet[0];
            }
            else
            {
                Console.WriteLine(pFounds.ToString());
                Console.WriteLine("Choose with ID : ");
                int choice = int.Parse(Console.ReadLine());
                planetOfTheCharacter = pFounds.getPlanetByID(choice);
            }


            Console.WriteLine("Firstname : ");
            string firstnameOfCharacter = Console.ReadLine();

            Console.WriteLine("Lastname : ");
            string lastnameOfCharacter = Console.ReadLine();

            Console.WriteLine("Age : ");
            int ageOfCharacter = int.Parse(Console.ReadLine());

            Console.WriteLine("Race : ");
            string raceOfCharacter = Console.ReadLine();

            Console.WriteLine("Type of soldier : ");
            string stringTOSOfCharacter = Console.ReadLine();

            TypeOfSoldier TOSOfCharacter = TypeOfSoldier.Other;

            switch (stringTOSOfCharacter)
            {
            case "Jedi":
                TOSOfCharacter = TypeOfSoldier.Jedi;
                break;

            case "Sith":
                TOSOfCharacter = TypeOfSoldier.Sith;
                break;

            case "Trooper":
                TOSOfCharacter = TypeOfSoldier.Trooper;
                break;

            case "Droide":
                TOSOfCharacter = TypeOfSoldier.Droide;
                break;

            case "Gungan":
                TOSOfCharacter = TypeOfSoldier.Gungan;
                break;
            }

            Character newCharacter = new Character();

            Console.WriteLine("Is he dead ? (y/n)");
            string answer = Console.ReadLine();

            if (answer == "y" || answer == "Y")
            {
                Console.WriteLine("Year of death :");
                int yearOfDeathOfTheCharacter = int.Parse(Console.ReadLine());
                newCharacter = new DeadCharacter(characters.ListCharacter.Count, firstnameOfCharacter, lastnameOfCharacter, ageOfCharacter, raceOfCharacter, TOSOfCharacter, yearOfDeathOfTheCharacter);
            }
            else
            {
                newCharacter = new Character(characters.ListCharacter.Count, firstnameOfCharacter, lastnameOfCharacter, ageOfCharacter, raceOfCharacter, TOSOfCharacter);
            }
            planetOfTheCharacter.addCharacter(newCharacter);
            characters.addCharacter(newCharacter);
            Console.WriteLine("The chararcter has been added !");
            displayBackMenu();
        }