Exemple #1
0
        private static void SoldierActions()
        {
            ManageIO manageIO = new ManageIO();
            int      option;
            bool     keepdoing = true;

            while (keepdoing)
            {
                OptionsSoldier();
                option = manageIO.inInt();

                switch (option)
                {
                case 1:
                    soldier.Shoot("enemigo");
                    break;

                case 2:
                    soldier.ChangeWeapon(new SniperRifle());
                    break;

                case 3:
                    soldier.ChangeWeapon(new GranadeLauncher());
                    break;

                case 4:
                    keepdoing = false;
                    break;

                default:
                    Console.WriteLine("La opció no es válida!");
                    break;
                }
            }
        }
Exemple #2
0
        private static void SelectCharacter()
        {
            ManageIO manageIO = new ManageIO();
            int      option;
            bool     keepdoing = true;

            while (keepdoing)
            {
                MenuSelectCharacter();
                option = manageIO.inInt();

                switch (option)
                {
                case 1:
                    SoldierActions();
                    break;

                case 2:
                    TankActions();
                    break;

                case 3:
                    keepdoing = false;
                    break;

                default:
                    Console.WriteLine("La opció no es válida!");
                    break;
                }
            }
        }
Exemple #3
0
        private static void TankActions()
        {
            ManageIO manageIO = new ManageIO();
            int      option;
            bool     keepdoing = true;

            while (keepdoing)
            {
                OptionsTank();
                option = manageIO.inInt();

                switch (option)
                {
                case 1:
                    tank.Shoot("enemigo");
                    break;

                case 2:
                    keepdoing = false;
                    break;

                default:
                    Console.WriteLine("La opció no es válida!");
                    break;
                }
            }
        }
Exemple #4
0
        private IWeapon SelectWeapon()
        {
            ManageIO manageIO = new ManageIO();
            int      option;

            Console.WriteLine("\n-- Armas del tanque --");
            Console.WriteLine("1 - " + this.cannon.GetName());
            Console.WriteLine("2 - " + this.antiAircraft.GetName());
            Console.WriteLine("3 - " + this.machineGun.GetName());
            Console.Write("Escoge una opción: ");
            option = manageIO.inInt();


            if (option == 1)
            {
                return(this.cannon);
            }
            if (option == 2)
            {
                return(this.antiAircraft);
            }
            else
            {
                return(this.machineGun);
            }
        }
Exemple #5
0
        public Option GetOption()
        {
            ManageIO manageIO = new ManageIO();
            int      option;
            bool     error = true;

            do
            {
                Console.Write("\nEscull una opció [1 - " + _quantity + "]: ");
                option = manageIO.inInt();
                error  = !_options.ContainsKey(option);
                if (error)
                {
                    Console.WriteLine("Error!!! La opció ha d'estar entre 1 y " + _quantity);
                }
            } while (error);

            return(_options[option]);
        }