Ejemplo n.º 1
0
        static Universe()
        {
            kingdoms = new Dictionary <string, Kingdom>();
            Kingdom Space = new Kingdom("SPACE", "Gorilla", "Shan");

            kingdoms.Add("SPACE", Space);

            Kingdom Land = new Kingdom("LAND", "Panda");

            kingdoms.Add("LAND", Land);

            Kingdom Water = new Kingdom("WATER", "Octopus");

            kingdoms.Add("WATER", Water);

            Kingdom Ice = new Kingdom("ICE", "Mammoth");

            kingdoms.Add("ICE", Ice);

            Kingdom Air = new Kingdom("AIR", "Owl");

            kingdoms.Add("AIR", Air);

            Kingdom Fire = new Kingdom("FIRE", "Dragon");

            kingdoms.Add("FIRE", Fire);

            Priest = new HighPriest();
        }
Ejemplo n.º 2
0
 private void SendMessagetoKingdomsFromBalltoBox(HighPriest p)
 {
     foreach (var item in SixMessageFromBallotBox)
     {
         if (!Universe.kingdoms[item.ToKingdom.Name].alligencegiven)
         {
             if (Universe.kingdoms[item.ToKingdom.Name].receiveMessageAndAddAllies(item.Message, item.FromKingdom, item.ToKingdom, p))
             {
                 Universe.kingdoms[item.ToKingdom.Name].alligencegiven = true;
             }
         }
     }
 }
Ejemplo n.º 3
0
        static void Main()
        {
            Universe       Sotheros           = new Universe();
            HighPriest     priest             = Universe.Priest;
            List <Kingdom> CompitetorsKingdom = new List <Kingdom>();

            GetRulerAndAllies(CompitetorsKingdom.FirstOrDefault());
            Console.WriteLine("Enter the kingdoms competing to be the ruler:");
            List <string> input = Convert.ToString(Console.ReadLine()).Split(' ').ToList();
            string        mesg  = Validation.ValidateKingdoms(input);

            while (mesg != "sucess")
            {
                Console.WriteLine(mesg + " \nPlease Enter the Kingdom who is there in the universe");
                input = Convert.ToString(Console.ReadLine()).Split(' ').ToList();
                mesg  = Validation.ValidateKingdoms(input);
            }
            int count = 1;

            while (Sotheros.KingOfall == null)
            {
                Console.WriteLine("Reuslt after round " + count + " ballet count");
                if (count == 1)
                {
                    priest.AddCompitetors(input);
                }

                string result = priest.ConductElection();
                CompitetorsKingdom = priest.DisplayAlliesForCompitetors();
                if (CompitetorsKingdom != null && CompitetorsKingdom.Count == 1)
                {
                    Sotheros.KingOfall = CompitetorsKingdom.FirstOrDefault();
                    GetRulerAndAllies(CompitetorsKingdom.FirstOrDefault());
                }
                else if (CompitetorsKingdom != null && CompitetorsKingdom.Count > 1)
                {
                    priest.ModifyCompiteors(CompitetorsKingdom);
                }

                count++;
                if (count == 1000)
                {
                    Console.WriteLine("Not able to decided the King since they have equal share in all rounds.");
                    break;
                }
            }
            Console.Read();
        }
Ejemplo n.º 4
0
 public bool receiveMessageAndAddAllies(string message, Kingdom fromKingdom, Kingdom toKingdom, HighPriest p)
 {
     if (p.Compitetors.Contains(toKingdom.Name))
     {
         return(false);
     }
     if (Kingdom.ProcessreceivedMessage(message, Emblem.ToLower().ToCharArray()))
     {
         AddAllies(fromKingdom, toKingdom);
         return(true);
     }
     return(false);
 }