Beispiel #1
0
        private static void ChangeRankMenu(Military mil)
        {
            while (true)
            {
                Console.WriteLine("Select new rank:");
                Console.WriteLine("0. Private");
                Console.WriteLine("1. Sergeant");
                Console.WriteLine("2. Major");
                Console.WriteLine("3. Colonel");
                int key;
                try { key = Convert.ToInt32(Console.ReadLine()); }
                catch (Exception e) { Console.Clear(); Console.WriteLine("The input must be a number between 0 and 3"); continue; }
                switch (key)
                {
                case 0: mil.ChangeRank(new Private(mil.Fullname)); break;

                case 1: mil.ChangeRank(new Sergeant(mil.Fullname)); break;

                case 2: mil.ChangeRank(new Major(mil.Fullname)); break;

                case 3: mil.ChangeRank(new Colonel(mil.Fullname)); break;

                default:
                {
                    Console.Clear();
                    Console.WriteLine("The input must be a number between 0 and 3");
                    continue;
                }
                }
                Console.Clear();
                break;
            }
        }
Beispiel #2
0
        private static void GetMilitaryMenu()
        {
            int id;

            while (true)
            {
                Console.WriteLine("Enter military id:");
                try { id = Convert.ToInt32(Console.ReadLine()); }
                catch (Exception e) { Console.Clear(); Console.WriteLine("The id must be a number"); continue; }
                if (id < 0)
                {
                    Console.Clear();
                    Console.WriteLine("The id must be a positive number");
                }
                else
                {
                    break;
                }
            }
            Military mil = DataBase.militaryBase.GetMilitary(id);

            if (mil != null)
            {
                Console.Clear();
                MilitaryInfoMenu(mil);
            }
            else
            {
                Console.Clear();
                Console.WriteLine($"There is no military with id {id}");
            }
        }
Beispiel #3
0
        public void GoToArmy(Builder builder)
        {
            builder.Reset(this);
            Director.createMilitary(builder);
            Military mil = builder.GetResult();

            DataBase.militaryBase.AddMilitary(mil);
            DataBase.ukraine.RemoveMan(Id);
        }
Beispiel #4
0
        private static void ChangeWeaponMenu(Military mil)
        {
            string title;
            int    ammo;
            int    acc;
            int    nois;

            while (true)
            {
                Console.WriteLine("Enter weapon Title:");
                title = Console.ReadLine();
                if (title.Length == 0)
                {
                    Console.Clear();
                    Console.WriteLine("Weapon title can't be an empty string");
                    continue;
                }
                break;
            }
            while (true)
            {
                Console.WriteLine("Enter maximum weapon Ammunition:");
                try { ammo = Convert.ToInt32(Console.ReadLine()); }
                catch (Exception e) { Console.Clear(); Console.WriteLine("The input must be a number"); continue; }
                if (ammo <= 0)
                {
                    Console.Clear(); Console.WriteLine("The input must be a positive number"); continue;
                }
                break;
            }
            while (true)
            {
                Console.WriteLine("Enter weapon Accuracy:");
                try { acc = Convert.ToInt32(Console.ReadLine()); }
                catch (Exception e) { Console.Clear(); Console.WriteLine("The input must be a number"); continue; }
                if (acc <= 0)
                {
                    Console.Clear(); Console.WriteLine("The input must be a positive number"); continue;
                }
                break;
            }
            while (true)
            {
                Console.WriteLine("Enter weapon Noisiness:");
                try { nois = Convert.ToInt32(Console.ReadLine()); }
                catch (Exception e) { Console.Clear(); Console.WriteLine("The input must be a number"); continue; }
                if (nois <= 0)
                {
                    Console.Clear(); Console.WriteLine("The input must be a positive number"); continue;
                }
                break;
            }
            mil.weapon = new RealWeapon(title, ammo, acc, nois);
        }
Beispiel #5
0
        private static void OrderMenu(Military mil)
        {
            string order;

            while (true)
            {
                Console.WriteLine("Enter an order:");
                order = Console.ReadLine();
                if (order.Length == 0)
                {
                    Console.Clear();
                    Console.WriteLine("The order can't be an empty string");
                    continue;
                }
                break;
            }
            Console.Clear();
            mil.ExecuteOrder(order);
        }
Beispiel #6
0
        private static void MilitaryInfoMenu(Military mil)
        {
            while (true)
            {
                mil.Display();
                Console.WriteLine("Choose an action:");
                Console.WriteLine("1. Change rank");
                Console.WriteLine("2. Order");
                Console.WriteLine("3. Change Weapon");
                Console.WriteLine("4. Set Silencer on weapon");
                Console.WriteLine("5. Set Sight on weapon");
                Console.WriteLine("0. Go Back");
                int key;
                try { key = Convert.ToInt32(Console.ReadLine()); }
                catch (Exception e) { Console.Clear(); Console.WriteLine("The input must be a number between 0 and 3"); continue; }
                switch (key)
                {
                case 1: { Console.Clear(); ChangeRankMenu(mil); } break;

                case 2: { Console.Clear(); OrderMenu(mil); } break;

                case 3: { Console.Clear(); ChangeWeaponMenu(mil); } break;

                case 4: { Console.Clear(); mil.weapon = new SilencerDecorator(mil.weapon); } break;

                case 5: { Console.Clear(); mil.weapon = new SightDecorator(mil.weapon); } break;

                case 0: { Console.Clear(); return; };

                default:
                {
                    Console.Clear();
                    Console.WriteLine("The input must be a number between 0 and 3");
                    continue;
                }
                }
            }
        }
Beispiel #7
0
 public void AddMilitary(Military military)
 {
     militaries.Add(military);
 }