示例#1
0
        public static State RandomState()
        {
            Monarchy monarchy = new Monarchy();

            // Creating the element.
            for (int i = 0; i < rnd.Next(4, 20); i++)
            {
                monarchy.Name                   += (char)rnd.Next(65, 91);
                monarchy.LeaderName             += (char)rnd.Next(97, 123);
                monarchy.Age                    += rnd.Next(0, 150);
                monarchy.Population             += rnd.Next(0, 1000);
                monarchy.Continent              += (char)rnd.Next(97, 123);
                monarchy.CurrentRullingClanName += (char)rnd.Next(65, 91);
            }

            return(monarchy);
        }
示例#2
0
        // Function to input a monarchy object.
        public static State ObjectInput()
        {
            Monarchy monarchy = new Monarchy();

            // Name input.
            Console.Write("Enter the name: ");
            monarchy.Name = Console.ReadLine();

            // Leader name input.
            Console.Write("Enter the leader's name: ");
            monarchy.LeaderName = Console.ReadLine();

            // Population input.
            bool ok;
            int  buf;

            do
            {
                Console.Write("Enter the population: ");
                ok = Int32.TryParse(Console.ReadLine(), out buf);
                if (!ok || buf < 0)
                {
                    Console.WriteLine("Input error! Perhaps you didn't enter a natural number");
                }
            } while (!ok || buf < 0);

            monarchy.Population = buf;

            // Age input.
            do
            {
                Console.Write("Enter the age: ");
                ok = Int32.TryParse(Console.ReadLine(), out buf);
                if (!ok || buf < 0)
                {
                    Console.WriteLine("Input error! Perhaps you didn't enter a natural number");
                }
            } while (!ok || buf < 0);

            monarchy.Age = buf;

            // Continent input.
            monarchy.Continent = ContinentsInput();

            return(monarchy);
        }
示例#3
0
        public static Monarchy Generate(int a)
        {
            Monarchy monarchy = new Monarchy();

            string[] continents = { "Asia", "Africa", "America", "Oceania", "Europe" };

            // Creating the element.
            for (int i = 0; i < rnd.Next(4, 20); i++)
            {
                monarchy.Name                   += (char)rnd.Next(65, 91);
                monarchy.LeaderName             += (char)rnd.Next(97, 123);
                monarchy.Age                    += rnd.Next(0, 150);
                monarchy.Population             += rnd.Next(0, 1000);
                monarchy.CurrentRullingClanName += (char)rnd.Next(65, 91);
            }

            monarchy.Continent = continents[rnd.Next(0, 5)];

            return(monarchy);
        }