Example #1
0
 private void ExcuteCommand(string[] cmdArgs, CarManager carManager)
 {
     if (cmdArgs[0] == "register")
     {
         carManager.Register(int.Parse(cmdArgs[1]), cmdArgs[2], cmdArgs[3], cmdArgs[4], int.Parse(cmdArgs[5]), int.Parse(cmdArgs[6]), int.Parse(cmdArgs[7]), int.Parse(cmdArgs[8]), int.Parse(cmdArgs[9]));
     }
     else if (cmdArgs[0] == "check")
     {
         Console.WriteLine(carManager.Check(int.Parse(cmdArgs[1])));
     }
     else if (cmdArgs[0] == "open")
     {
         carManager.Open(int.Parse(cmdArgs[1]), cmdArgs[2], int.Parse(cmdArgs[3]), cmdArgs[4], int.Parse(cmdArgs[5]));
     }
     else if (cmdArgs[0] == "participate")
     {
         carManager.Participate(int.Parse(cmdArgs[1]), int.Parse(cmdArgs[2]));
     }
     else if (cmdArgs[0] == "start")
     {
         Console.Write(carManager.Start(int.Parse(cmdArgs[1])));
     }
     else if (cmdArgs[0] == "park")
     {
         carManager.Park(int.Parse(cmdArgs[1]));
     }
     else if (cmdArgs[0] == "unpark")
     {
         carManager.Unpark(int.Parse(cmdArgs[1]));
     }
     else if (cmdArgs[0] == "tune")
     {
         carManager.Tune(int.Parse(cmdArgs[1]), cmdArgs[2]);
     }
 }
Example #2
0
    public void Run()
    {
        var input = string.Empty;

        while ((input = Console.ReadLine()) != "Cops Are Here")
        {
            var data    = input.Split();
            var command = data[0];

            switch (command)
            {
            case "register":
                manager.Register(int.Parse(data[1]), data[2], data[3],
                                 data[4], int.Parse(data[5]), int.Parse(data[6]),
                                 int.Parse(data[7]), int.Parse(data[8]), int.Parse(data[9]));
                break;

            case "open":
                if (data[2] == "TimeLimit" || data[2] == "Circuit")
                {
                    manager.Open(int.Parse(data[1]), data[2], int.Parse(data[3]), data[4], int.Parse(data[5]), int.Parse(data[6]));
                }
                else
                {
                    manager.Open(int.Parse(data[1]), data[2], int.Parse(data[3]), data[4], int.Parse(data[5]));
                }
                break;

            case "participate":
                //participate 3 3
                manager.Participate(int.Parse(data[1]), int.Parse(data[2]));
                break;

            case "check":
                //check 5
                Console.WriteLine(manager.Check(int.Parse(data[1])).Trim());
                break;

            case "start":
                //start 1
                Console.WriteLine(manager.Start(int.Parse(data[1])).Trim());
                break;

            case "park":
                //park 5
                manager.Park(int.Parse(data[1]));
                break;

            case "tune":
                //tune 100 Nitrous
                manager.Tune(int.Parse(data[1]), data[2]);
                break;

            case "unpark":
                manager.Unpark(int.Parse(data[1]));
                break;
            }
        }
    }
Example #3
0
        static void Main(string[] args)
        {
            CarManager carManager      = new CarManager();
            List <int> IdOfClosedRaces = new List <int>();
            var        input           = string.Empty;

            while ((input = Console.ReadLine()) != "Cops Are Here")
            {
                var inputTokens = input
                                  .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                                  .ToList();
                var command = inputTokens[0];
                switch (command)
                {
                case "register":
                    carManager.Register(int.Parse(inputTokens[1]), inputTokens[2], inputTokens[3], inputTokens[4], int.Parse(inputTokens[5]), int.Parse(inputTokens[6]), int.Parse(inputTokens[7]), int.Parse(inputTokens[8]), int.Parse(inputTokens[9]));
                    break;

                case "check":
                    Console.WriteLine(carManager.Check(int.Parse(inputTokens[1])));
                    break;

                case "open":
                    carManager.Open(int.Parse(inputTokens[1]), inputTokens[2], int.Parse(inputTokens[3]), inputTokens[4], int.Parse(inputTokens[5]));
                    break;

                case "participate":
                    if (!IdOfClosedRaces.Contains(int.Parse(inputTokens[2])))
                    {
                        carManager.Participate(int.Parse(inputTokens[1]), int.Parse(inputTokens[2]));
                    }
                    break;

                case "start":
                    if (!IdOfClosedRaces.Contains(int.Parse(inputTokens[1])))
                    {
                        Console.WriteLine(carManager.Start(int.Parse(inputTokens[1])));
                        IdOfClosedRaces.Add(int.Parse(inputTokens[1]));
                    }
                    break;

                case "park":
                    carManager.Park(int.Parse(inputTokens[1]));
                    break;

                case "unpark":
                    carManager.Unpark(int.Parse(inputTokens[1]));
                    break;

                case "tune":
                    carManager.Tune(int.Parse(inputTokens[1]), inputTokens[2]);
                    break;

                default:
                    break;
                }
            }
        }
Example #4
0
    private static void Main(string[] args)
    {
        var manager = new CarManager();

        var input = Console.ReadLine();

        while (input != "Cops Are Here")
        {
            var tokens = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            switch (tokens[0])
            {
            case "register":
                manager.Register(int.Parse(tokens[1]), tokens[2], tokens[3], tokens[4], int.Parse(tokens[5]), int.Parse(tokens[6]), int.Parse(tokens[7]), int.Parse(tokens[8]), int.Parse(tokens[9]));
                break;

            case "check":
                Console.WriteLine(manager.Check(int.Parse(tokens[1])));
                break;

            case "open":
                if (tokens[2] == "TimeLimit" || tokens[2] == "Circuit")
                {
                    manager.Open(int.Parse(tokens[1]), tokens[2], int.Parse(tokens[3]), tokens[4], int.Parse(tokens[5]), int.Parse(tokens[6]));
                }
                else
                {
                    manager.Open(int.Parse(tokens[1]), tokens[2], int.Parse(tokens[3]), tokens[4], int.Parse(tokens[5]));
                }
                break;

            case "participate":
                manager.Participate(int.Parse(tokens[1]), int.Parse(tokens[2]));
                break;

            case "start":
                Console.WriteLine(manager.Start(int.Parse(tokens[1])));
                break;

            case "park":
                manager.Park(int.Parse(tokens[1]));
                break;

            case "unpark":
                manager.Unpark(int.Parse(tokens[1]));
                break;

            case "tune":
                manager.Tune(int.Parse(tokens[1]), tokens[2]);
                break;

            default:
                break;
            }

            input = Console.ReadLine();
        }
    }
Example #5
0
    public static void Main()
    {
        string     input = Console.ReadLine();
        CarManager cm    = new CarManager();

        while (input != "Cops Are Here")
        {
            List <string> args   = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            string        action = args[0];

            args = args.Skip(1).ToList();
            switch (action)
            {
            case "register":
                cm.Register(int.Parse(args[0]), args[1], args[2], args[3], int.Parse(args[4]),
                            int.Parse(args[5]), int.Parse(args[6]), int.Parse(args[7]), int.Parse(args[8]));
                break;

            case "check":
                Console.WriteLine(cm.Check(int.Parse(args[0])));
                break;

            case "open":
                if (args.Count == 6)
                {
                    cm.Open(int.Parse(args[0]), args[1], int.Parse(args[2]), args[3], int.Parse(args[4]),
                            args[5]);
                }
                else
                {
                    cm.Open(int.Parse(args[0]), args[1], int.Parse(args[2]), args[3], int.Parse(args[4]));
                }
                break;

            case "participate":
                cm.Participate(int.Parse(args[0]), int.Parse(args[1]));
                break;

            case "start":
                Console.WriteLine(cm.Start(int.Parse(args[0])));
                break;

            case "park":
                cm.Park(int.Parse(args[0]));
                break;

            case "unpark":
                cm.Unpark(int.Parse(args[0]));
                break;

            case "tune":
                cm.Tune(int.Parse(args[0]), args[1]);
                break;
            }

            input = Console.ReadLine();
        }
    }
Example #6
0
    public void ExecuteCommand(string[] cmdArgs)
    {
        switch (cmdArgs[0])
        {
        case "register":
            int    id               = int.Parse(cmdArgs[1]);
            string type             = cmdArgs[2];
            string brand            = cmdArgs[3];
            string model            = cmdArgs[4];
            int    yearOfProduction = int.Parse(cmdArgs[5]);
            int    horsepower       = int.Parse(cmdArgs[6]);
            int    acceleration     = int.Parse(cmdArgs[7]);
            int    suspension       = int.Parse(cmdArgs[8]);
            int    durability       = int.Parse(cmdArgs[9]);
            manager.Register(id, type, brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        case "check":
            Console.WriteLine(manager.Check(int.Parse(cmdArgs[1])));
            break;

        case "open":
            id   = int.Parse(cmdArgs[1]);
            type = cmdArgs[2];
            int    length   = int.Parse(cmdArgs[3]);
            string route    = cmdArgs[4];
            int    prizePoo = int.Parse(cmdArgs[5]);
            manager.Open(id, type, length, route, prizePoo);
            break;

        case "participate":
            int carId  = int.Parse(cmdArgs[1]);
            int raceId = int.Parse(cmdArgs[2]);
            manager.Participate(carId, raceId);
            break;

        case "start":
            raceId = int.Parse(cmdArgs[1]);
            Console.WriteLine(manager.Start(raceId));
            break;

        case "park":
            carId = int.Parse(cmdArgs[1]);
            manager.Park(carId);
            break;

        case "unpark":
            carId = int.Parse(cmdArgs[1]);
            manager.Unpark(carId);
            break;

        case "tune":
            int    tuneIndex = int.Parse(cmdArgs[1]);
            string tuneAddOn = cmdArgs[2];
            manager.Tune(tuneIndex, tuneAddOn);
            break;
        }
    }
    static void Main()
    {
        string     input   = Console.ReadLine();
        CarManager manager = new CarManager();

        while (!input.Equals("Cops Are Here"))
        {
            string[] args    = input.Split();
            string   command = args[0];

            switch (command)
            {
            case "register":
                manager.Register(int.Parse(args[1]), args[2], args[3], args[4], int.Parse(args[5]), int.Parse(args[6]), int.Parse(args[7]), int.Parse(args[8]), int.Parse(args[9]));
                break;

            case "check":
                Console.WriteLine(manager.Check(int.Parse(args[1])));
                break;

            case "open":

                if (args.Length == 6)
                {
                    manager.Open(int.Parse(args[1]), args[2], int.Parse(args[3]), args[4], int.Parse(args[5]));
                    break;
                }
                else     // special race - one parameter more
                {
                    manager.Open(int.Parse(args[1]), args[2], int.Parse(args[3]), args[4], int.Parse(args[5]), int.Parse(args[6]));
                    break;
                }

            case "participate":
                manager.Participate(int.Parse(args[1]), int.Parse(args[2]));
                break;

            case "start":
                Console.WriteLine(manager.Start(int.Parse(args[1])));
                break;

            case "park":
                manager.Park(int.Parse(args[1]));
                break;

            case "unpark":
                manager.Unpark(int.Parse(args[1]));
                break;

            case "tune":
                manager.Tune(int.Parse(args[1]), args[2]);
                break;
            }

            input = Console.ReadLine();
        }
    }
    public void StartUp()
    {
        string     inputLine;
        CarManager manager = new CarManager();

        while ((inputLine = Console.ReadLine()) != "Cops Are Here")
        {
            var commandTokens = inputLine.Split();

            var command = commandTokens[0];
            var id      = int.Parse(commandTokens[1]);
            switch (command)
            {
            case "register":
                RegisterVehicle(commandTokens, manager);
                break;

            case "check":
                var result = manager.Check(id);
                Console.WriteLine(result);
                break;

            case "open":
                var type      = commandTokens[2];
                var length    = int.Parse(commandTokens[3]);
                var route     = commandTokens[4];
                var prizePool = int.Parse(commandTokens[5]);

                manager.Open(id, type, length, route, prizePool);
                break;

            case "participate":
                var raceId = int.Parse(commandTokens[2]);

                manager.Participate(id, raceId);
                break;

            case "start":
                var winners = manager.Start(id);
                Console.WriteLine(winners);
                break;

            case "park":
                manager.Park(id);
                break;

            case "unpark":
                manager.Unpark(id);
                break;

            case "tune":
                manager.Tune(id, commandTokens[2]);
                break;
            }
        }
    }
Example #9
0
    private void CommandDistributor(string inputData)
    {
        List <string> data       = inputData.Split().ToList();
        Func <int>    getId      = () => int.Parse(data[1]);
        Func <int>    getRace    = () => int.Parse(data[2]);
        Func <int>    getYear    = () => int.Parse(data[5]);
        Func <int>    getPower   = () => int.Parse(data[6]);
        Func <int>    getAcc     = () => int.Parse(data[7]);
        Func <int>    getSusp    = () => int.Parse(data[8]);
        Func <int>    getDur     = () => int.Parse(data[9]);
        Func <int>    getLength  = () => int.Parse(data[3]);
        Func <int>    getPrize   = () => int.Parse(data[5]);
        int           timeORlaps = 0;

        switch (data[0])
        {
        case "register":
            manager.Register(getId(), data[2], data[3], data[4], getYear(), getPower(), getAcc(), getSusp(), getDur());
            break;

        case "check":
            Console.WriteLine(manager.Check(getId()));
            break;

        case "open":
            if (data[2] == "Circuit" || data[2] == "TimeLimit")
            {
                timeORlaps = int.Parse(data[6]);
            }
            manager.Open(getId(), data[2], getLength(), data[4], getPrize(), timeORlaps);
            break;

        case "participate":
            manager.Participate(getId(), getRace());
            break;

        case "start":
            Console.WriteLine(manager.Start(getId()));
            break;

        case "park":
            manager.Park(getId());
            break;

        case "unpark":
            manager.Unpark(getId());
            break;

        case "tune":
            manager.Tune(getId(), data[2]);
            break;

        default:
            break;
        }
    }
Example #10
0
    public static void Main()
    {
        var carManager = new CarManager();
        var input = Console.ReadLine().Split();

        while (input[0] != "Cops")
        {
            var number = int.Parse(input[1]);
            switch (input[0])
            {
                case "register":
                    carManager.Register(number, input[2], input[3], input[4], int.Parse(input[5]), int.Parse(input[6]), int.Parse(input[7]), int.Parse(input[8]), int.Parse(input[9]));
                    break;

                case "check":
                    Console.WriteLine(carManager.Check(number));
                    break;

                case "open":
                    if (input.Length == 6)
                    {
                        carManager.Open(number, input[2], int.Parse(input[3]), input[4], int.Parse(input[5]));
                    }
                    else
                    {
                        carManager.OpenSpecial(number, input[2], int.Parse(input[3]), input[4], int.Parse(input[5]),
                            int.Parse(input[6]));
                    }
                    break;

                case "participate":
                    carManager.Participate(number, int.Parse(input[2]));
                    break;

                case "start":
                    Console.WriteLine(carManager.Start(number));
                    break;

                case "park":
                    carManager.Park(number);
                    break;

                case "unpark":
                    carManager.Unpark(number);
                    break;

                case "tune":
                    carManager.Tune(number, input[2]);
                    break;
            }

            input = Console.ReadLine().Split();
        }
    }
Example #11
0
    public void Start()
    {
        string input = Console.ReadLine();

        while (input != "Cops Are Here")
        {
            string[] inputParts = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            string   command    = inputParts[0];
            switch (command)
            {
            case "register":
                this.carManager.Register(int.Parse(inputParts[1]), inputParts[2], inputParts[3], inputParts[4], int.Parse(inputParts[5]), int.Parse(inputParts[6]),
                                         int.Parse(inputParts[7]), int.Parse(inputParts[8]), int.Parse(inputParts[9]));
                break;

            case "check":
                Console.WriteLine(carManager.Check(int.Parse(inputParts[1])));
                break;

            case "open":
                if (inputParts.Length == 6)
                {
                    this.carManager.Open(int.Parse(inputParts[1]), inputParts[2], int.Parse(inputParts[3]), inputParts[4], int.Parse(inputParts[5]));
                }
                else
                {
                    this.carManager.OpenSpecialRace(int.Parse(inputParts[1]), inputParts[2], int.Parse(inputParts[3]), inputParts[4], int.Parse(inputParts[5]), int.Parse(inputParts[6]));
                }
                break;

            case "participate":
                this.carManager.Participate(int.Parse(inputParts[1]), int.Parse(inputParts[2]));
                break;

            case "start":
                Console.WriteLine(carManager.Start(int.Parse(inputParts[1])));
                break;

            case "park":
                this.carManager.Park(int.Parse(inputParts[1]));
                break;

            case "unpark":
                this.carManager.Unpark(int.Parse(inputParts[1]));
                break;

            case "tune":
                this.carManager.Tune(int.Parse(inputParts[1]), inputParts[2]);
                break;
            }
            input = Console.ReadLine();
        }
    }
Example #12
0
    private static void ParseCommand(string command)
    {
        var line = command.Split(' ');

        switch (line[0])
        {
        case "register":
            int    id               = int.Parse(line[1]);
            string type             = line[2];
            string brand            = line[3];
            string model            = line[4];
            int    yearOfProduction = int.Parse(line[5]);
            int    horsepower       = int.Parse(line[6]);
            int    acceleration     = int.Parse(line[7]);
            int    suspension       = int.Parse(line[8]);
            int    durability       = int.Parse(line[9]);
            manager.Register(id, type, brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        case "check":
            Console.WriteLine(manager.Check(int.Parse(line[1])));
            break;

        case "open":
            var input = line.Skip(1).ToList();
            manager.Open(input);
            break;

        case "participate":
            int carId   = int.Parse(line[1]);
            int raceIds = int.Parse(line[2]);
            manager.Participate(carId, raceIds);
            break;

        case "start":
            Console.WriteLine(manager.Start(int.Parse(line[1])));
            break;

        case "unpark":
            manager.Unpark(int.Parse(line[1]));
            break;

        case "park":
            manager.Park(int.Parse(line[1]));
            break;

        case "tune":
            int    tuneIndex = int.Parse(line[1]);
            string addon     = line[2];
            manager.Tune(tuneIndex, addon);
            break;
        }
    }
Example #13
0
    private void ExecuteCommand(string[] comdArg)
    {
        switch (comdArg[0])
        {
        case "register":
            int    id               = int.Parse(comdArg[1]);
            string type             = comdArg[2];
            string brand            = comdArg[3];
            string model            = comdArg[4];
            int    yearOfProduction = int.Parse(comdArg[5]);
            int    horsepower       = int.Parse(comdArg[6]);;
            int    acceleration     = int.Parse(comdArg[7]);;
            int    suspension       = int.Parse(comdArg[8]);;
            int    durability       = int.Parse(comdArg[9]);;
            manager.Register(id, type, brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        case "check":
            Console.WriteLine(manager.Check(int.Parse(comdArg[1])));
            break;

        case "open":
            manager.Open(int.Parse(comdArg[1]), comdArg[2], int.Parse(comdArg[3]), comdArg[4], int.Parse(comdArg[5]));
            break;

        case "participate":
            var carId  = int.Parse(comdArg[1]);
            var raceId = int.Parse(comdArg[2]);
            manager.Participate(carId, raceId);
            break;

        case "start":
            raceId = int.Parse(comdArg[1]);
            Console.WriteLine(manager.Start(raceId));
            break;

        case "park":
            id = int.Parse(comdArg[1]);
            manager.Park(id);
            break;

        case "unpark":
            id = int.Parse(comdArg[1]);
            manager.Unpark(id);
            break;

        case "tune":
            var tuneIndex = int.Parse(comdArg[1]);
            var addOn     = comdArg[2];
            manager.Tune(tuneIndex, addOn);
            break;
        }
    }
Example #14
0
    private void ProcessCommand(string command, List <string> commandArgs)
    {
        int id = int.Parse(commandArgs[0]);

        commandArgs = commandArgs.Skip(1).ToList();

        switch (command)
        {
        case "register":
            string type  = commandArgs[0];
            string brand = commandArgs[1];
            string model = commandArgs[2];
            int    year  = int.Parse(commandArgs[3]);
            int    hp    = int.Parse(commandArgs[4]);
            int    acc   = int.Parse(commandArgs[5]);
            int    sus   = int.Parse(commandArgs[6]);
            int    dur   = int.Parse(commandArgs[7]);
            carManager.Register(id, type, brand, model, year, hp, acc, sus, dur);
            break;

        case "check":
            OutputWriter(carManager.Check(id));
            break;

        case "open":
            carManager.Open(id, commandArgs[0], int.Parse(commandArgs[1]), commandArgs[2],
                            int.Parse(commandArgs[3]));
            break;

        case "participate":
            carManager.Participate(id, int.Parse(commandArgs[0]));
            break;

        case "start":
            OutputWriter(carManager.Start(id));
            break;

        case "park":
            carManager.Park(id);
            break;

        case "unpark":
            carManager.Unpark(id);
            break;

        case "tune":
            carManager.Tune(id, commandArgs[0]);
            break;

        default:
            throw new InvalidOperationException("No such command exists");
        }
    }
Example #15
0
    static void Main(string[] args)
    {
        var input = Console.ReadLine();

        var manager = new CarManager();

        while (input != "Cops Are Here")
        {
            var command = input
                          .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                          .ToList();

            switch (command[0])
            {
            case "register":
                manager.Register(int.Parse(command[1]), command[2], command[3], command[4], int.Parse(command[5]),
                                 int.Parse(command[6]), int.Parse(command[7]), int.Parse(command[8]), int.Parse(command[9]));
                break;

            case "check":
                Console.WriteLine(manager.Check(int.Parse(command[1])));
                break;

            case "open":
                manager.Open(int.Parse(command[1]), command[2], int.Parse(command[3]), command[4], int.Parse(command[5]), command.Count > 6 ? int.Parse(command[6]) : 0);
                break;

            case "participate":
                manager.Participate(int.Parse(command[1]), int.Parse(command[2]));
                break;

            case "start":
                Console.WriteLine(manager.Start(int.Parse(command[1])));
                break;

            case "park":
                manager.Park(int.Parse(command[1]));
                break;

            case "unpark":
                manager.Unpark(int.Parse(command[1]));
                break;

            case "tune":
                manager.Tune(int.Parse(command[1]), command[2]);
                break;
            }

            input = Console.ReadLine();
        }
    }
Example #16
0
    public static void Main()
    {
        var input = Console.ReadLine();

        var carManager = new CarManager();

        while (input != "Cops Are Here")
        {
            var tokens = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var cmd    = tokens[0];

            switch (cmd)
            {
            case "register":
                RegisteredCar(carManager, tokens);
                break;

            case "check":
                var result = carManager.Check(int.Parse(tokens[1]));
                Console.WriteLine(result);
                break;

            case "open":
                OpenRace(carManager, tokens);
                break;

            case "participate":
                carManager.Participate(int.Parse(tokens[1]), int.Parse(tokens[2]));
                break;

            case "start":
                result = carManager.Start(int.Parse(tokens[1]));
                Console.WriteLine(result);
                break;

            case "park":
                carManager.Park(int.Parse(tokens[1]));
                break;

            case "unpark":
                carManager.Unpark(int.Parse(tokens[1]));
                break;

            case "tune":
                carManager.Tune(int.Parse(tokens[1]), tokens[2]);
                break;
            }

            input = Console.ReadLine();
        }
    }
Example #17
0
    public void Run()
    {
        string[] input = Console.ReadLine().Split(new[] { '\n', '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();

        while (input[0] != "Cops")
        {
            switch (input[0].ToLower())
            {
            case "register":
                manager.Register(int.Parse(input[1]), input[2], input[3], input[4], int.Parse(input[5]),
                                 int.Parse(input[6]), int.Parse(input[7]), int.Parse(input[8]), int.Parse(input[9]));
                break;

            case "check":
                Console.WriteLine(manager.Check(int.Parse(input[1])));
                break;

            case "open":
                if (input[1] == "CircuitRace" || input[1] == "TimeLimitRace")
                {
                    manager.Open(int.Parse(input[1]), input[2], int.Parse(input[3]), input[4], int.Parse(input[5]), int.Parse(input[6]));
                }
                else
                {
                    manager.Open(int.Parse(input[1]), input[2], int.Parse(input[3]), input[4], int.Parse(input[5]));
                }
                break;

            case "participate":
                manager.Participate(int.Parse(input[1]), int.Parse(input[2]));
                break;

            case "start":
                Console.WriteLine(manager.Start(int.Parse(input[1])));
                break;

            case "park":
                manager.Park(int.Parse(input[1]));
                break;

            case "unpark":
                manager.Unpark(int.Parse(input[1]));
                break;

            case "tune":
                manager.Tune(int.Parse(input[1]), string.Join(" ", input.Skip(2).ToArray()));
                break;
            }
            input = Console.ReadLine().Split(new[] { '\n', '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
    static void Main()
    {
        CarManager manager = new CarManager();
        string     input;

        while ((input = Console.ReadLine()) != "Cops Are Here")
        {
            string[] tolkens = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            string   command = tolkens[0];
            string   result  = string.Empty;
            switch (command.ToLower())
            {
            case "register":
                manager.Register(int.Parse(tolkens[1]), tolkens[2], tolkens[3], tolkens[4], int.Parse(tolkens[5]), int.Parse(tolkens[6]), int.Parse(tolkens[7]), int.Parse(tolkens[8]), int.Parse(tolkens[9]));
                break;

            case "check":
                result = manager.Check(int.Parse(tolkens[1]));
                Console.WriteLine(result);
                break;

            case "open":
                manager.Open(int.Parse(tolkens[1]), tolkens[2], int.Parse(tolkens[3]), tolkens[4], int.Parse(tolkens[5]));
                break;

            case "participate":
                manager.Participate(int.Parse(tolkens[1]), int.Parse(tolkens[2]));
                break;

            case "start":
                result = manager.Start(int.Parse(tolkens[1]));
                Console.WriteLine(result);
                break;

            case "park":
                manager.Park(int.Parse(tolkens[1]));
                break;

            case "unpark":
                manager.Unpark(int.Parse(tolkens[1]));
                break;

            case "tune":
                manager.Tune(int.Parse(tolkens[1]), tolkens[2]);
                break;
            }
        }
    }
Example #19
0
    public static void Main(string[] args)
    {
        CarManager manager = new CarManager();

        while (true)
        {
            var input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (input[0] == "Cops")
            {
                break;
            }

            if (input[0] == "register")
            {
                manager.Register(int.Parse(input[1]), input[2], input[3], input[4], int.Parse(input[5])
                                 , int.Parse(input[6]), int.Parse(input[7]), int.Parse(input[8]), int.Parse(input[9]));
            }
            else if (input[0] == "open")
            {
                manager.Open(int.Parse(input[1]), input[2], int.Parse(input[3]), input[4], int.Parse(input[5]));
            }
            else if (input[0] == "participate")
            {
                manager.Participate(int.Parse(input[1]), int.Parse(input[2]));
            }
            else if (input[0] == "check")
            {
                Console.WriteLine(manager.Check(int.Parse(input[1])));
            }
            else if (input[0] == "park")
            {
                manager.Park(int.Parse(input[1]));
            }
            else if (input[0] == "unpark")
            {
                manager.Unpark(int.Parse(input[1]));
            }
            else if (input[0] == "tune")
            {
                manager.Tune(int.Parse(input[1]), input[2]);
            }
            else if (input[0] == "start")
            {
                Console.WriteLine(manager.Start(int.Parse(input[1])));
            }
        }
    }
Example #20
0
        static void Main(string[] args)
        {
            var manager = new CarManager();

            string line;

            while ((line = Console.ReadLine()) != "Cops Are Here")
            {
                var tokens = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();

                switch (tokens[0])
                {
                case "register":
                    manager.Register(int.Parse(tokens[1]), tokens[2], tokens[3], tokens[4], int.Parse(tokens[5]), int.Parse(tokens[6]), int.Parse(tokens[7]), int.Parse(tokens[8]), int.Parse(tokens[9]));
                    break;

                case "check":
                    Console.WriteLine(manager.Check(int.Parse(tokens[1])));
                    break;

                case "open":
                    manager.Open(int.Parse(tokens[1]), tokens[2], int.Parse(tokens[3]), tokens[4], int.Parse(tokens[5]));
                    break;

                case "participate":
                    manager.Participate(int.Parse(tokens[1]), int.Parse(tokens[2]));
                    break;

                case "start":
                    Console.WriteLine(manager.Start(int.Parse(tokens[1])));
                    break;

                case "park":
                    manager.Park(int.Parse(tokens[1]));
                    break;

                case "unpark":
                    manager.Unpark(int.Parse(tokens[1]));
                    break;

                case "tune":
                    manager.Tune(int.Parse(tokens[1]), tokens[2]);
                    break;
                }
            }
        }
    public void ReadCommand(string command)
    {
        var cmdArgs = command.Split();

        switch (cmdArgs[0].ToLower())
        {
        case "register":
            carManager.Register(int.Parse(cmdArgs[1]), cmdArgs[2], cmdArgs[3], cmdArgs[4], int.Parse(cmdArgs[5]),
                                int.Parse(cmdArgs[6]), int.Parse(cmdArgs[7]), int.Parse(cmdArgs[8]), int.Parse(cmdArgs[9]));
            break;

        case "check":
            Console.Write(carManager.Check(int.Parse(cmdArgs[1])));
            break;

        case "open":
            carManager.Open(int.Parse(cmdArgs[1]), cmdArgs[2], int.Parse(cmdArgs[3]), cmdArgs[4], int.Parse(cmdArgs[5]));
            break;

        case "participate":
            carManager.Participate(int.Parse(cmdArgs[1]), int.Parse(cmdArgs[2]));
            break;

        case "start":
            Console.Write(carManager.Start(int.Parse(cmdArgs[1])));
            break;

        case "park":
            carManager.Park(int.Parse(cmdArgs[1]));
            break;

        case "unpark":
            carManager.Unpark(int.Parse(cmdArgs[1]));
            break;

        case "tune":
            carManager.Tune(int.Parse(cmdArgs[1]), cmdArgs[2]);
            break;
        }
    }
Example #22
0
    public void Run()
    {
        CarManager cm = new CarManager();

        string command;

        while ((command = Console.ReadLine()) != Constants.END_OF_PROGRAM)
        {
            var cmdArgs = command.Split();

            int    id;
            string type;
            string cmdType = cmdArgs[0];
            switch (cmdType)
            {
            case "register":
                id   = int.Parse(cmdArgs[1]);
                type = cmdArgs[2];
                string brand        = cmdArgs[3];
                string model        = cmdArgs[4];
                int    year         = int.Parse(cmdArgs[5]);
                int    horsepower   = int.Parse(cmdArgs[6]);
                int    acceleration = int.Parse(cmdArgs[7]);
                int    suspension   = int.Parse(cmdArgs[8]);
                int    durability   = int.Parse(cmdArgs[9]);

                cm.Register(id, type, brand, model, year, horsepower, acceleration, suspension, durability);
                break;

            case "check":
                id = int.Parse(cmdArgs[1]);

                Console.WriteLine(cm.Check(id));
                break;

            case "open":
                id   = int.Parse(cmdArgs[1]);
                type = cmdArgs[2];
                int    length    = int.Parse(cmdArgs[3]);
                string route     = cmdArgs[4];
                int    prizePool = int.Parse(cmdArgs[5]);
                int    bonus     = 0;

                if (type == "TimeLimit" || type == "Circuit")
                {
                    bonus = int.Parse(cmdArgs[6]);
                }

                cm.Open(id, type, length, route, prizePool, bonus);
                break;

            case "participate":
                int carId  = int.Parse(cmdArgs[1]);
                int raceId = int.Parse(cmdArgs[2]);

                cm.Participate(carId, raceId);
                break;

            case "start":
                id = int.Parse(cmdArgs[1]);

                if (!cm.Races[id].IsRaceFinished)
                {
                    string raceResult = cm.Start(id);
                    Console.WriteLine(raceResult);
                }
                break;

            case "park":
                id = int.Parse(cmdArgs[1]);

                cm.Park(id);
                break;

            case "unpark":
                id = int.Parse(cmdArgs[1]);

                cm.Unpark(id);
                break;

            case "tune":
                int    tuneIndex = int.Parse(cmdArgs[1]);
                string addOn     = cmdArgs[2];

                cm.Tune(tuneIndex, addOn);
                break;

            default:
                break;
            }
        }
    }
Example #23
0
    public void Run()
    {
        CarManager manager = new CarManager();

        string type;
        string brand;
        string model;
        int    year;
        int    horsepower;
        int    acceleration;
        int    suspension;
        int    durability;
        int    length;
        string route;
        int    prizePool;
        int    carId;
        int    raceId;
        int    tuneIndex;
        string tuneAddon;

        var input = Console.ReadLine().Split(new[] { ' ', '\t', '\n' }, StringSplitOptions.RemoveEmptyEntries);

        while (input[0] != "Cops")
        {
            var command = input[0];

            switch (command.ToLower())
            {
            case "register":
                carId        = int.Parse(input[1]);
                type         = input[2];
                brand        = input[3];
                model        = input[4];
                year         = int.Parse(input[5]);
                horsepower   = int.Parse(input[6]);
                acceleration = int.Parse(input[7]);
                suspension   = int.Parse(input[8]);
                durability   = int.Parse(input[9]);
                manager.Register(carId, type, brand, model, year, horsepower, acceleration, suspension, durability);
                break;

            case "check":
                carId = int.Parse(input[1]);
                Console.WriteLine(manager.Check(carId));
                break;

            case "open":
                raceId    = int.Parse(input[1]);
                type      = input[2];
                length    = int.Parse(input[3]);
                route     = input[4];
                prizePool = int.Parse(input[5]);
                manager.Open(raceId, type, length, route, prizePool);
                break;

            case "participate":
                carId  = int.Parse(input[1]);
                raceId = int.Parse(input[2]);
                manager.Participate(carId, raceId);
                break;

            case "start":
                raceId = int.Parse(input[1]);
                Console.WriteLine(manager.Start(raceId));
                break;

            case "park":
                carId = int.Parse(input[1]);
                manager.Park(carId);
                break;

            case "unpark":
                carId = int.Parse(input[1]);
                manager.Unpark(carId);
                break;

            case "tune":
                tuneIndex = int.Parse(input[1]);
                tuneAddon = input[2];
                manager.Tune(tuneIndex, tuneAddon);
                break;

            default:
                break;
            }

            input = Console.ReadLine().Split(new[] { ' ', '\t', '\n' }, StringSplitOptions.RemoveEmptyEntries);
        }
    }
Example #24
0
    static void Main()
    {
        string command = Console.ReadLine();

        string[]   commands   = command.Split(' ').ToArray();
        CarManager carManager = new CarManager();

        while (command != "Cops Are Here")
        {
            switch (commands[0])
            {
            case "register":
                int    id               = int.Parse(commands[1]);
                string type             = commands[2];
                string brand            = commands[3];
                string model            = commands[4];
                int    yearOfProduction = int.Parse(commands[5]);
                int    horsepower       = int.Parse(commands[6]);
                int    acceleration     = int.Parse(commands[7]);
                int    suspension       = int.Parse(commands[8]);
                int    durability       = int.Parse(commands[9]);
                carManager.Register(id, type, brand, model, yearOfProduction, horsepower, acceleration, suspension,
                                    durability);
                break;

            case "check":

                Console.WriteLine(carManager.Check(int.Parse(commands[1])));

                break;

            case "open":
                carManager.Open(int.Parse(commands[1]), commands[2], int.Parse(commands[3]), commands[4], int.Parse(commands[5]));
                break;

            case "participate":
                carManager.Participate(int.Parse(commands[1]), int.Parse(commands[2]));    //add car to Participents


                break;

            case "start":
                Console.WriteLine(carManager.Start(int.Parse(commands[1])));
                break;

            case "park":    //?

                carManager.Park(int.Parse(commands[1]));
                break;

            case "unpark":
                carManager.Unpark(int.Parse(commands[1]));
                break;

            case "tune":

                carManager.Tune(int.Parse(commands[1]), commands[2]);
                break;
            }

            command  = Console.ReadLine();
            commands = command.Split(' ').ToArray();
        }
    }
Example #25
0
    static void Main(string[] args)
    {
        CarManager carManager = new CarManager();

        while (true)
        {
            string   end   = Console.ReadLine();
            string[] input = end.Split();
            if (end == "Cops Are Here")
            {
                break;
            }

            switch (input[0])
            {
            case "register":
                var id               = int.Parse(input[1]);
                var type             = input[2];
                var brand            = input[3];
                var model            = input[4];
                var yearOfProduction = int.Parse(input[5]);
                var horsepower       = int.Parse(input[6]);
                var acceleration     = int.Parse(input[7]);
                var suspension       = int.Parse(input[8]);
                var durability       = int.Parse(input[9]);
                carManager.Register(id, type, brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
                break;

            case "check":
                Console.WriteLine(carManager.Check(int.Parse(input[1])));
                break;

            case "open":
                var idO       = int.Parse(input[1]);
                var typeO     = input[2];
                var length    = int.Parse(input[3]);
                var route     = input[4];
                var prizePool = int.Parse(input[5]);
                if (input.Length == 7)
                {
                    var extraParameter = int.Parse(input[6]);
                    carManager.Open(idO, typeO, length, route, prizePool, extraParameter);
                }
                else
                {
                    carManager.Open(idO, typeO, length, route, prizePool);
                }
                break;

            case "participate":
                var carId  = int.Parse(input[1]);
                var raceId = int.Parse(input[2]);
                carManager.Participate(carId, raceId);
                break;

            case "start":
                Console.WriteLine(carManager.Start(int.Parse(input[1])));
                break;

            case "park":
                carManager.Park(int.Parse(input[1]));
                break;

            case "unpark":
                carManager.Unpark(int.Parse(input[1]));
                break;

            case "tune":
                carManager.Tune(int.Parse(input[1]), input[2]);
                break;
            }
        }
    }
Example #26
0
    public void ExecuteCommand(string[] commandArgs)
    {
        var    command = commandArgs[0];
        int    id;
        string type;

        switch (command)
        {
        case "register":
            id   = int.Parse(commandArgs[1]);
            type = commandArgs[2];
            var brand            = commandArgs[3];
            var model            = commandArgs[4];
            var yearOfProduction = int.Parse(commandArgs[5]);
            var horsepower       = int.Parse(commandArgs[6]);
            var acceleration     = int.Parse(commandArgs[7]);
            var suspension       = int.Parse(commandArgs[8]);
            var durability       = int.Parse(commandArgs[9]);

            manager.Register(id, type, brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        case "check":
            id = int.Parse(commandArgs[1]);
            Console.WriteLine(manager.Check(id));
            break;

        case "open":
            id   = int.Parse(commandArgs[1]);
            type = commandArgs[2];
            int    length    = int.Parse(commandArgs[3]);
            string route     = commandArgs[4];
            int    prizePool = int.Parse(commandArgs[5]);

            if (commandArgs.Length > 6)
            {
                int specialParam = int.Parse(commandArgs[6]);
                manager.Open(id, type, length, route, prizePool, specialParam);
            }
            else
            {
                manager.Open(id, type, length, route, prizePool);
            }

            break;

        case "participate":
            var carId  = int.Parse(commandArgs[1]);
            var raceId = int.Parse(commandArgs[2]);
            manager.Participate(carId, raceId);
            break;

        case "start":
            raceId = int.Parse(commandArgs[1]);
            Console.WriteLine(manager.Start(raceId));
            break;

        case "park":
            carId = int.Parse(commandArgs[1]);
            manager.Park(carId);
            break;

        case "unpark":
            carId = int.Parse(commandArgs[1]);
            manager.Unpark(carId);
            break;

        case "tune":
            int    tuneIndex = int.Parse(commandArgs[1]);
            string addOn     = commandArgs[2];
            manager.Tune(tuneIndex, addOn);
            break;

        default: break;
        }
    }
Example #27
0
    private void ExecuteCommand(string[] cmdArg)
    {
        int    id;
        string type;
        string brand;
        string model;
        int    year;
        int    horsePower;
        int    acceleration;
        int    suspension;
        int    durability;
        int    carId;
        int    raceId;
        int    length;
        string route;
        int    prizePool;

        switch (cmdArg[0])
        {
        case "register":
            id           = int.Parse(cmdArg[1]);
            type         = cmdArg[2];
            brand        = cmdArg[3];
            model        = cmdArg[4];
            year         = int.Parse(cmdArg[5]);
            horsePower   = int.Parse(cmdArg[6]);
            acceleration = int.Parse(cmdArg[7]);
            suspension   = int.Parse(cmdArg[8]);
            durability   = int.Parse(cmdArg[9]);
            manager.Register(id, type, brand, model, year, horsePower, acceleration, suspension, durability);
            break;

        case "check":
            id = int.Parse(cmdArg[1]);
            Console.WriteLine(manager.Check(id));
            break;

        case "open":
            id        = int.Parse(cmdArg[1]);
            type      = cmdArg[2];
            length    = int.Parse(cmdArg[3]);
            route     = cmdArg[4];
            prizePool = int.Parse(cmdArg[5]);
            manager.Open(id, type, length, route, prizePool);
            break;

        case "participate":
            carId  = int.Parse(cmdArg[1]);
            raceId = int.Parse(cmdArg[2]);
            manager.Participate(carId, raceId);
            break;

        case "start":
            raceId = int.Parse(cmdArg[1]);
            Console.WriteLine(manager.Start(raceId));
            ;
            break;

        case "park":
            carId = int.Parse(cmdArg[1]);
            manager.Park(carId);
            break;

        case "unpark":
            carId = int.Parse(cmdArg[1]);
            manager.Unpark(carId);
            break;

        case "tune":
            int    tuneIndex = int.Parse(cmdArg[1]);
            string addon     = cmdArg[2];
            manager.Tune(tuneIndex, addon);
            break;
        }
    }
    private void Execute(string[] command)
    {
        int    id;
        string type;
        int    raceId;

        switch (command[0])
        {
        case "register":
            id   = int.Parse(command[1]);
            type = command[2];
            var brand            = command[3];
            var model            = command[4];
            var yearOfProduction = int.Parse(command[5]);
            var horsepower       = int.Parse(command[6]);
            var acceleration     = int.Parse(command[7]);
            var suspension       = int.Parse(command[8]);
            var durability       = int.Parse(command[9]);

            manager.Register(id, type, brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        case "check":
            id = int.Parse(command[1]);
            Console.WriteLine(manager.Check(id));
            break;

        case "open":
            id   = int.Parse(command[1]);
            type = command[2];
            var length    = int.Parse(command[3]);
            var route     = command[4];
            var pricePool = int.Parse(command[5]);

            manager.Open(id, type, length, route, pricePool);
            break;

        case "participate":
            var carId = int.Parse(command[1]);
            raceId = int.Parse(command[2]);

            manager.Participate(carId, raceId);
            break;

        case "start":
            raceId = int.Parse(command[1]);

            Console.WriteLine(manager.Start(raceId));
            break;

        case "park":
            carId = int.Parse(command[1]);

            manager.Park(carId);
            break;

        case "unpark":
            carId = int.Parse(command[1]);

            manager.Unpark(carId);
            break;

        case "tune":
            var tuneIndex = int.Parse(command[1]);
            var addOn     = command[2];

            manager.Tune(tuneIndex, addOn);
            break;
        }
    }
Example #29
0
    public void Run()
    {
        var command = Console.ReadLine();

        while (command != "Cops Are Here")
        {
            var cmdArg = command.Split();

            int    id;
            string type;
            int    raceId;

            switch (cmdArg[0])
            {
            case "register":
                id   = int.Parse(cmdArg[1]);
                type = cmdArg[2];
                string brand            = cmdArg[3];
                string model            = cmdArg[4];
                int    yearOfProduction = int.Parse(cmdArg[5]);
                int    horsepower       = int.Parse(cmdArg[6]);
                int    acceleration     = int.Parse(cmdArg[7]);
                int    suspension       = int.Parse(cmdArg[8]);
                int    durability       = int.Parse(cmdArg[9]);
                manager.Register(id, type, brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
                break;

            case "check":
                Console.WriteLine(manager.Check(int.Parse(cmdArg[1])));
                break;

            case "open":
                id   = int.Parse(cmdArg[1]);
                type = cmdArg[2];
                int    length    = int.Parse(cmdArg[3]);
                string route     = cmdArg[4];
                int    prizePool = int.Parse(cmdArg[5]);
                manager.Open(id, type, length, route, prizePool);
                break;

            case "participate":
                int carId = int.Parse(cmdArg[1]);
                raceId = int.Parse(cmdArg[2]);
                manager.Participate(carId, raceId);
                break;

            case "start":
                raceId = int.Parse(cmdArg[1]);
                Console.WriteLine(manager.Start(raceId));

                break;

            case "park":
                id = int.Parse(cmdArg[1]);
                manager.Park(id);
                break;

            case "unpark":
                id = int.Parse(cmdArg[1]);
                manager.Unpark(id);
                break;

            case "tune":
                int    tuneIndex = int.Parse(cmdArg[1]);
                string addOns    = cmdArg[2];
                manager.Tune(tuneIndex, addOns);
                break;
            }

            command = Console.ReadLine();
        }
    }
Example #30
0
    static void Main(string[] args)
    {
        var input      = Console.ReadLine();
        var carManager = new CarManager();

        while (input != "Cops Are Here")
        {
            var infoParts = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            var typeOfCommand = infoParts[0];

            if (typeOfCommand == "register")
            {
                var id         = int.Parse(infoParts[1]);
                var carType    = infoParts[2];
                var brand      = infoParts[3];
                var model      = infoParts[4];
                var year       = int.Parse(infoParts[5]);
                var hp         = int.Parse(infoParts[6]);
                var acc        = int.Parse(infoParts[7]);
                var suspension = int.Parse(infoParts[8]);
                var durability = int.Parse(infoParts[9]);

                carManager.Register(id, carType, brand, model, year, hp, acc, suspension, durability);
            }
            else if (typeOfCommand == "participate")
            {
                var carId  = int.Parse(infoParts[1]);
                var raceId = int.Parse(infoParts[2]);

                carManager.Participate(carId, raceId);
            }
            else if (typeOfCommand == "open")
            {
                if (infoParts.Length < 7)
                {
                    var id       = int.Parse(infoParts[1]);
                    var raceType = infoParts[2];
                    var length   = int.Parse(infoParts[3]);
                    var route    = infoParts[4];
                    var price    = int.Parse(infoParts[5]);

                    carManager.Open(id, raceType, length, route, price);
                }
                else
                {
                    var id        = int.Parse(infoParts[1]);
                    var raceType  = infoParts[2];
                    var length    = int.Parse(infoParts[3]);
                    var route     = infoParts[4];
                    var price     = int.Parse(infoParts[5]);
                    var lastParam = int.Parse(infoParts[6]);

                    carManager.Open(id, raceType, length, route, price, lastParam);
                }
            }
            else if (typeOfCommand == "check")
            {
                var id = int.Parse(infoParts[1]);

                Console.WriteLine(carManager.Check(id));
            }
            else if (typeOfCommand == "start")
            {
                var id = int.Parse(infoParts[1]);

                Console.WriteLine(carManager.Start(id));
            }
            else if (typeOfCommand == "park")
            {
                var id = int.Parse(infoParts[1]);

                carManager.Park(id);
            }
            else if (typeOfCommand == "unpark")
            {
                var id = int.Parse(infoParts[1]);

                carManager.Unpark(id);
            }
            else if (typeOfCommand == "tune")
            {
                var tuneIndex = int.Parse(infoParts[1]);
                var addOn     = infoParts[2];

                carManager.Tune(tuneIndex, addOn);
            }

            input = Console.ReadLine();
        }
    }