Example #1
0
        public static void Main()
        {
            var raceRepo       = new RaceRepository();
            var riderRepo      = new RiderRepository();
            var motorcycleRepo = new MotorcycleRepository();

            var raceFactory       = new RaceFactory();
            var riderFactory      = new RiderFactory();
            var motorcycleFactory = new MotorcycleFactory();

            var championshipController = new ChampionshipController(
                raceRepo,
                riderRepo,
                motorcycleRepo,
                raceFactory,
                riderFactory,
                motorcycleFactory);

            var consoleReader = new ConsoleReader();
            var consoleWriter = new ConsoleWriter();

            var engine = new Engine(
                championshipController,
                consoleReader,
                consoleWriter);

            engine.Run();
        }
Example #2
0
        public static void Main(string[] args)
        {
            //TODO Add IEngine
            //Motorcycle varche = new PowerMotorcycle("12214235", 75);
            //Console.WriteLine(varche.HorsePower);
            IMotorcycleFactory motorcycleFactory = new MotorcycleFactory();
            IRaceFactory       raceFactory       = new RaceFactory();
            IRiderFactory      riderFactory      = new RiderFactory();

            MotorcycleRepository motorcycleRepository = new MotorcycleRepository();
            RaceRepository       raceRepository       = new RaceRepository();
            RiderRepository      riderRepository      = new RiderRepository();

            IChampionshipController controller = new ChampionshipController(
                motorcycleFactory,
                raceFactory,
                riderFactory,
                motorcycleRepository,
                raceRepository,
                riderRepository);

            IReader reader = new ConsoleReader();
            IWriter writer = new ConsoleWriter();

            IEngine engine = new Engine(reader, writer, controller);

            engine.Run();
        }
Example #3
0
        public static void Main(string[] args)
        {
            IReader reader = new ConsoleReader();
            IWriter writer = new ConsoleWriter();

            IRepository <IMotorcycle> motorcycleRepository = new MotorcycleRepository();
            IRepository <IRace>       raceRepository       = new RaceRepository();
            IRepository <IRider>      riderRepository      = new RiderRepository();

            MotorcycleFactory motorcycleFactory = new MotorcycleFactory();

            // Judge system does not require dependency inversion principle to be observed!
            // Also Factories and CommandInterpreter are not required!

            IChampionshipController championshipController = new ChampionshipController(
                motorcycleRepository,
                raceRepository,
                riderRepository,
                motorcycleFactory);

            ICommandInterpreter commandInterpreter = new CommandInterpreter(championshipController);

            IEngine engine = new Engine(commandInterpreter, reader, writer);

            engine.Run();
        }
Example #4
0
        public static void Main(string[] args)
        {
            IChampionshipController championShipController = new ChampionshipController();

            var newEngine = new Engine(championShipController);

            newEngine.Run();
        }
Example #5
0
        public static void Main(string[] args)
        {
            IReader reader = new ConsoleReader();
            IWriter writer = new ConsoleWriter();
            IChampionshipController controller = new ChampionshipController();

            var engine = new Engine(writer, reader, controller);

            engine.Run();
        }
Example #6
0
        public static void Main(string[] args)
        {
            IChampionshipController championshipController = new ChampionshipController();

            IReader consoleReader = new ConsoleReader();
            IWriter consoleWriter = new ConsoleWriter();

            IEngine engine = new Engine(consoleReader, consoleWriter, championshipController);

            engine.Run();
        }
        public static void Main(string[] args)
        {
            ////TODO Add IEngine
            //Motorcycle varche = new PowerMotorcycle("12214235", 75);
            //Console.WriteLine(varche.HorsePower);
            IReader reader = new ConsoleReader();
            IWriter writer = new ConsoleWriter();
            ChampionshipController championshipController = new ChampionshipController();
            IEngine engine = new Engine(championshipController, writer, reader);

            engine.Run();
        }
        public static void Main(string[] args)
        {
            ChampionshipController controller = new ChampionshipController();

            string line = Console.ReadLine();

            while (line != "End")
            {
                string[] commandItems = line.Split();
                string   result       = string.Empty;

                try
                {
                    switch (commandItems[0])
                    {
                    case "CreateRider":
                        result += controller.CreateRider(commandItems[1]);
                        break;

                    case "CreateMotorcycle":
                        result += controller.CreateMotorcycle(commandItems[1],
                                                              commandItems[2],
                                                              int.Parse(commandItems[3]));
                        break;

                    case "AddMotorcycleToRider":
                        result += controller.AddMotorcycleToRider(commandItems[1], commandItems[2]);
                        break;

                    case "AddRiderToRace":
                        result += controller.AddRiderToRace(commandItems[1], commandItems[2]);
                        break;

                    case "CreateRace":
                        result += controller.CreateRace(commandItems[1], int.Parse(commandItems[2]));
                        break;

                    case "StartRace":
                        result += controller.StartRace(commandItems[1]);
                        break;
                    }

                    Console.WriteLine(result);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                line = Console.ReadLine();
            }
        }
        public static void Main(string[] args)
        {
            StringBuilder message = new StringBuilder();

            string result = string.Empty;
            ChampionshipController championshipController = new ChampionshipController();
            string input = string.Empty;

            while ((input = Console.ReadLine()) != "End")
            {
                try
                {
                    string[] elements = input
                                        .Split(" ")
                                        .ToArray();

                    string command = elements[0];

                    if (command == "CreateRider")
                    {
                        string name = elements[1];
                        result = championshipController.CreateRider(name);
                    }
                    else if (command == "CreateMotorcycle")
                    {
                        string type       = elements[1];
                        string model      = elements[2];
                        int    horsePower = int.Parse(elements[3]);

                        result = championshipController.CreateMotorcycle(type, model, horsePower);
                    }
                    else if (command == "AddMotorcycleToRider")
                    {
                        string nameRider = elements[1];
                        string nameMotor = elements[2];

                        result = championshipController.AddMotorcycleToRider(nameRider, nameMotor);
                    }
                    else if (command == "AddRiderToRace")
                    {
                        string nameRace = elements[1];
                        string nameRide = elements[2];

                        result = championshipController.AddRiderToRace(nameRace, nameRide);
                    }
                    else if (command == "CreateRace")
                    {
                        string name = elements[1];
                        int    labs = int.Parse(elements[2]);

                        result = championshipController.CreateRace(name, labs);
                    }
                    else if (command == "StartRace")
                    {
                        string name = elements[1];
                        result = championshipController.StartRace(name);
                    }
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }

                message.AppendLine(result);
            }

            Console.WriteLine(message);
        }