Exemplo n.º 1
0
        public string Execute()
        {
            switch (this.Name)
            {
            case "HirePilot":
                return(machinesManager.HirePilot(this.Data[0]));

            case "ManufactureTank":
                return(machinesManager.ManufactureTank(this.Data[0], double.Parse(this.Data[1]), double.Parse(this.Data[2])));

            case "ManufactureFighter":
                return(machinesManager.ManufactureFighter(this.Data[0], double.Parse(this.Data[1]), double.Parse(this.Data[2])));

            case "Engage":
                return(machinesManager.EngageMachine(this.Data[0], this.Data[1]));

            case "Attack":
                return(machinesManager.AttackMachines(this.Data[0], this.Data[1]));

            case "PilotReport":
                return(machinesManager.PilotReport(this.Data[0]));

            case "MachineReport":
                return(machinesManager.MachineReport(this.Data[0]));

            case "AggressiveMode":
                return(machinesManager.ToggleFighterAggressiveMode(this.Data[0]));

            case "DefenseMode":
                return(machinesManager.ToggleTankDefenseMode(this.Data[0]));

            default:
                throw new Exception();
            }
        }
Exemplo n.º 2
0
        public void Run()
        {
            string[] commands = this.reader.ReadLine().Split().ToArray();

            while (commands[0] != "Quit")
            {
                try
                {
                    string result = string.Empty;

                    switch (commands[0])
                    {
                    case "HirePilot":
                        result = controller.HirePilot(commands[1]);
                        break;

                    case "PilotReport":
                        result = controller.PilotReport(commands[1]);
                        break;

                    case "ManufactureTank":
                        result = controller.ManufactureTank(commands[1], int.Parse(commands[2]), int.Parse(commands[3]));
                        break;

                    case "ManufactureFighter":
                        result = controller.ManufactureFighter(commands[1], int.Parse(commands[2]), int.Parse(commands[3]));
                        break;

                    case "MachineReport":
                        result = controller.MachineReport(commands[1]);
                        break;

                    case "AggressiveMode":
                        result = controller.ToggleFighterAggressiveMode(commands[1]);
                        break;

                    case "DefenseMode":
                        result = controller.ToggleTankDefenseMode(commands[1]);
                        break;

                    case "Engage":
                        result = controller.EngageMachine(commands[1], commands[2]);
                        break;

                    case "Attack":
                        result = controller.AttackMachines(commands[1], commands[2]);
                        break;
                    }

                    writer.WriteLine(result);
                    commands = reader.ReadLine().Split().ToArray();
                }
                catch (Exception ex)
                {
                    writer.WriteLine(ex.Message);
                }
            }
        }
Exemplo n.º 3
0
        public void MoveCommand(string inputLine, IMachinesManager mm)
        {
            string[] input   = inputLine.Split();
            string   command = input[0];

            switch (command)
            {
            case "HirePilot":
                Console.WriteLine(mm.HirePilot(input[1])); break;

            case "PilotReport":
                Console.WriteLine(mm.PilotReport(input[1])); break;

            case "ManufactureTank":
                Console.WriteLine(mm.ManufactureTank(input[1], double.Parse(input[2]), double.Parse(input[3]))); break;

            case "ManufactureFighter":
                Console.WriteLine(mm.ManufactureFighter(input[1], double.Parse(input[2]), double.Parse(input[3]))); break;

            case "MachineReport":
                Console.WriteLine(mm.MachineReport(input[1])); break;

            case "AggressiveMode":
                Console.WriteLine(mm.ToggleFighterAggressiveMode(input[1])); break;

            case "DefenseMode":
                Console.WriteLine(mm.ToggleTankDefenseMode(input[1])); break;

            case "Engage":
                Console.WriteLine(mm.EngageMachine(input[1], input[2])); break;

            case "Attack":
                Console.WriteLine(mm.AttackMachines(input[1], input[2])); break;

            default: break;
            }
        }
        public void Run()
        {
            var    sb    = new StringBuilder();
            string input = reader.ReadCommands();

            while (input != "Quit")
            {
                string[] tempArray = input.Split().ToArray();

                string typeOfCommnd = tempArray[0];
                string name         = tempArray[1];

                try
                {
                    switch (typeOfCommnd)
                    {
                    case "HirePilot":
                        sb.AppendLine(machinesManager.HirePilot(name));
                        break;

                    case "PilotReport":
                        sb.AppendLine(machinesManager.PilotReport(name));
                        break;

                    case "ManufactureTank":
                        sb.AppendLine(machinesManager.ManufactureTank(name, double.Parse(tempArray[2]), double.Parse(tempArray[3])));
                        break;

                    case "ManufactureFighter":
                        sb.AppendLine(machinesManager.ManufactureFighter(name, double.Parse(tempArray[2]), double.Parse(tempArray[3])));
                        break;

                    case "MachineReport":
                        sb.AppendLine(machinesManager.MachineReport(name));
                        break;

                    case "AggressiveMode":
                        sb.AppendLine(machinesManager.ToggleFighterAggressiveMode(name));
                        break;

                    case "DefenseMode":
                        sb.AppendLine(machinesManager.ToggleTankDefenseMode(name));
                        break;

                    case "Engage":
                        sb.AppendLine(machinesManager.EngageMachine(name, tempArray[2]));
                        break;

                    case "Attack":
                        sb.AppendLine(machinesManager.AttackMachines(name, tempArray[2]));
                        break;
                    }
                }
                catch (Exception ex)
                {
                    sb.AppendLine(ex.Message);
                }

                input = reader.ReadCommands();
            }

            writer.Write(sb.ToString().Trim());
        }
Exemplo n.º 5
0
        public void Run()
        {
            IList <ICommand> commands = reader.ReadCommands();

            foreach (ICommand command in commands)
            {
                try
                {
                    string[] commandParams = command.CommandParams;
                    switch (command.CommandType)
                    {
                    case "HirePilot":
                    {
                        writer.Write(machinesManager.HirePilot(commandParams[0]));
                    }
                    break;

                    case "PilotReport":
                    {
                        writer.Write(machinesManager.PilotReport(commandParams[0]));
                    }
                    break;

                    case "ManufactureTank":
                    {
                        writer.Write(machinesManager.ManufactureTank(commandParams[0], double.Parse(commandParams[1]), double.Parse(commandParams[2])));
                    }
                    break;

                    case "ManufactureFighter":
                    {
                        writer.Write(machinesManager.ManufactureFighter(commandParams[0], double.Parse(commandParams[1]), double.Parse(commandParams[2])));
                    }
                    break;

                    case "MachineReport":
                    {
                        writer.Write(machinesManager.MachineReport(commandParams[0]));
                    }
                    break;

                    case "AggressiveMode":
                    {
                        writer.Write(machinesManager.ToggleFighterAggressiveMode(commandParams[0]));
                    }
                    break;

                    case "DefenseMode":
                    {
                        writer.Write(machinesManager.ToggleTankDefenseMode(commandParams[0]));
                    }
                    break;

                    case "Engage":
                    {
                        writer.Write(machinesManager.EngageMachine(commandParams[0], commandParams[1]));
                    }
                    break;

                    case "Attack":
                    {
                        writer.Write(machinesManager.AttackMachines(commandParams[0], commandParams[1]));
                    }
                    break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    continue;
                }
            }
        }
Exemplo n.º 6
0
        public void Run()
        {
            while (true)
            {
                var    input   = Console.ReadLine().Split();
                string command = input[0];

                try
                {
                    string result = string.Empty;

                    switch (command)
                    {
                    case "HirePilot":
                        result = machinesManager.HirePilot(input[1]);
                        break;

                    case "PilotReport":
                        result = machinesManager.PilotReport(input[1]);
                        break;

                    case "ManufactureTank":
                        result = machinesManager.ManufactureTank(input[1], double.Parse(input[2]), double.Parse(input[3]));
                        break;

                    case "ManufactureFighter":
                        result = machinesManager.ManufactureFighter(input[1], double.Parse(input[2]), double.Parse(input[3]));
                        break;

                    case "MachineReport":
                        result = machinesManager.MachineReport(input[1]);
                        break;

                    case "AggressiveMode":
                        result = machinesManager.ToggleFighterAggressiveMode(input[1]);
                        break;

                    case "DefenseMode":
                        result = machinesManager.ToggleTankDefenseMode(input[1]);
                        break;

                    case "Engage":
                        result = machinesManager.EngageMachine(input[1], input[2]);
                        break;

                    case "Attack":
                        result = machinesManager.AttackMachines(input[1], input[2]);
                        break;

                    case "Quit":
                        return;

                    default:
                        break;
                    }

                    Console.WriteLine(result);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error: {ex.Message}");
                }
            }
        }