Example #1
0
        private int ChampionshipRequirementsMet(Championship championship)
        {
            int totalNumberOfRegulations = this.store.Count;
            int numberOfRegulationsMet   = 0;

            Championship vehicleSettings = new Championship();

            vehicleSettings.AllowedEngineLayouts      = (EngineLayouts)this.store["Layout"].Value;
            vehicleSettings.MaximumEngineDisplacement = (int)this.store["Displacement"].Value;
            vehicleSettings.AllowedFuels = (Fuels)this.store["Fuel"].Value;
            vehicleSettings.AllowedEngineSupercharged = (bool)this.store["Turbocharged/Supercharged"].Value;
            vehicleSettings.AllowedTransmissions      = (Transmissions)this.store["Transmission"].Value;
            vehicleSettings.AllowedDrives             = (Drives)this.store["Drive"].Value;
            vehicleSettings.MinimumNumberOfSeats      = (int)this.store["Number of seats"].Value;
            vehicleSettings.MinimumVehicleWeight      = (int)this.store["Weight"].Value;

            if ((championship.AllowedEngineLayouts & vehicleSettings.AllowedEngineLayouts) == vehicleSettings.AllowedEngineLayouts)
            {
                numberOfRegulationsMet++;
            }

            if (championship.MaximumEngineDisplacement >= vehicleSettings.MaximumEngineDisplacement)
            {
                numberOfRegulationsMet++;
            }

            if ((championship.AllowedFuels & vehicleSettings.AllowedFuels) == vehicleSettings.AllowedFuels)
            {
                numberOfRegulationsMet++;
            }

            if (championship.AllowedEngineSupercharged || championship.AllowedEngineSupercharged == vehicleSettings.AllowedEngineSupercharged)
            {
                numberOfRegulationsMet++;
            }

            if ((championship.AllowedTransmissions & vehicleSettings.AllowedTransmissions) == vehicleSettings.AllowedTransmissions)
            {
                numberOfRegulationsMet++;
            }

            if ((championship.AllowedDrives & vehicleSettings.AllowedDrives) == vehicleSettings.AllowedDrives)
            {
                numberOfRegulationsMet++;
            }

            if (championship.MinimumNumberOfSeats <= vehicleSettings.MinimumNumberOfSeats)
            {
                numberOfRegulationsMet++;
            }

            if (championship.MinimumVehicleWeight <= vehicleSettings.MinimumVehicleWeight)
            {
                numberOfRegulationsMet++;
            }

            return((numberOfRegulationsMet * 100) / totalNumberOfRegulations);
        }
Example #2
0
        private List <Championship> CreateChampionships()
        {
            Championship wrc = new Championship("WRC", EngineLayouts.I4, 1600, Fuels.Petrol, true, Transmissions.Manual | Transmissions.SemiAutomatic,
                                                Drives.FrontWheelDrive | Drives.RearWheelDrive | Drives.AllWheelDrive, 2, 1200);
            Championship formula1 = new Championship("Formula 1", EngineLayouts.V8, 2400, Fuels.Petrol, true, Transmissions.SemiAutomatic,
                                                     Drives.RearWheelDrive, 1, 580);
            Championship wtcc = new Championship("WTCC", EngineLayouts.I4, 2000, Fuels.Petrol | Fuels.Diesel, false,
                                                 Transmissions.Manual | Transmissions.SemiAutomatic, Drives.FrontWheelDrive | Drives.RearWheelDrive, 1, 1200);
            Championship dtm = new Championship("DTM", EngineLayouts.V8, 4000, Fuels.Petrol, false, Transmissions.SemiAutomatic,
                                                Drives.RearWheelDrive, 1, 1050);
            Championship superstars = new Championship("Superstars", EngineLayouts.V8, 7000, Fuels.Petrol | Fuels.Ethanol, false,
                                                       Transmissions.Manual | Transmissions.SemiAutomatic, Drives.RearWheelDrive, 4, 1350);

            return(new List <Championship>()
            {
                wrc, formula1, wtcc, dtm, superstars
            });
        }