Beispiel #1
0
        static void initForTest()
        {
            //Declare characters
            Character cYoda  = new Character(1, "Yoda", "No lastname", 800, "Unknown", TypeOfSoldier.Jedi);
            Character cJJB   = new Character(2, "Jar Jar", "Binks", 30, "Gungan", TypeOfSoldier.Gungan);
            Character cBenK  = new Character(3, "Ben", "Kenobi", 75, "Human", TypeOfSoldier.Jedi);
            Character cBenK2 = new Character(5, "Ben", "Kenobi2", 75, "Human", TypeOfSoldier.Jedi);
            Character cDV    = new Character(4, "Dark Vador", "No lastname", 75, "Human", TypeOfSoldier.Sith);

            //Declare Characters object
            characters = new Characters();

            //Add this characters into the list
            characters.addCharacter(cYoda);
            characters.addCharacter(cJJB);
            characters.addCharacter(cBenK);
            characters.addCharacter(cBenK2);
            characters.addCharacter(cDV);

            //Declare planets
            Planet pTatooine = new Planet(1, "Tatooine", "Mid Rim", 200000, "Basic", "Hot", new Characters());
            Planet pNaboo    = new Planet(2, "Naboo", "Mid Rim", 625000000, "Basic/Gungan", "Temperate", new Characters());

            //add characters for any planets
            pTatooine.addCharacter(cBenK);

            pNaboo.addCharacter(cJJB);

            //Declare Planets object
            planets = new Planets();

            //Add this planets into the Planets object
            planets.addPlanet(pTatooine);
            planets.addPlanet(pNaboo);
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
        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();
        }