internal static void randomCar(Common.FastRand rng, CarSalesSchema.Car.Builder car) { car.SetMake(MAKES[rng.nextLessThan(MAKES.Length)]); car.SetModel(MODELS[rng.nextLessThan(MODELS.Length)]); car.SetColor(colors[rng.nextLessThan((short)CarSalesSchema.Color.Silver + 1)]); car.SetSeats(unchecked ((byte)(2 + rng.nextLessThan(6)))); car.SetDoors(unchecked ((byte)(2 + rng.nextLessThan(3)))); foreach (CarSalesSchema.Wheel.Builder wheel in car.InitWheels(4)) { wheel.SetDiameter((ushort)(25 + rng.nextLessThan(15))); wheel.SetAirPressure((float)(30.0 + rng.nextDouble(20.0))); wheel.SetSnowTires(rng.nextLessThan(16) == 0); } car.SetLength((ushort)(170 + rng.nextLessThan(150))); car.SetWidth((ushort)(48 + rng.nextLessThan(36))); car.SetHeight((ushort)(54 + rng.nextLessThan(48))); car.SetWeight((uint)car.GetLength() * (uint)car.GetWidth() * (uint)car.GetHeight() / 200); CarSalesSchema.Engine.Builder engine = car.InitEngine(); engine.SetHorsepower((ushort)(100 * rng.nextLessThan(400))); engine.SetCylinders(unchecked ((byte)(4 + 2 * rng.nextLessThan(3)))); engine.SetCc((uint)(800 + rng.nextLessThan(10000))); engine.SetUsesGas(true); engine.SetUsesElectric(rng.nextLessThan(2) == 1); car.SetFuelCapacity((float)(10.0 + rng.nextDouble(30.0))); car.SetFuelLevel((float)(rng.nextDouble(car.GetFuelCapacity()))); car.SetHasPowerWindows(rng.nextLessThan(2) == 1); car.SetHasPowerSteering(rng.nextLessThan(2) == 1); car.SetHasCruiseControl(rng.nextLessThan(2) == 1); car.SetCupHolders(unchecked ((byte)rng.nextLessThan(12))); car.SetHasNavSystem(rng.nextLessThan(2) == 1); }
public sealed override ulong setupRequest(Common.FastRand rng, CarSalesSchema.ParkingLot.Builder request) { ulong result = 0; StructList.Builder <CarSalesSchema.Car.Builder> cars = request.InitCars(rng.nextLessThan(200)); for (int i = 0; i < cars.Length; ++i) { CarSalesSchema.Car.Builder car = cars.Get(i); randomCar(rng, car); result += carValue(car.AsReader()); } return(result); }