public JsonTruckInfo MapToTruckInfo(Truck truck, DateTime fromDate, DateTime toDate) { if (truck != null) { Location currentLocation = _dataService.GetCurrentLocation(truck.Id); JsonLocation jsonLocation = new JsonLocation { lat = currentLocation.Latitude, lng = currentLocation.Longitude }; List<JsonLocation> locations = _dataService.Locations .FilterBy(x => x.Truck.Id == truck.Id && x.Timestamp >= fromDate && x.Timestamp <= toDate) .OrderByDescending(c => c.Timestamp) .Select( location => new JsonLocation { lat = location.Latitude, lng = location.Longitude } ) .ToList(); JsonTruckInfo jsonTruckInfo = new JsonTruckInfo { name = truck.Name, plate = truck.PlateNumber, type = truck.Type, user = truck.User.FirstName + " " + truck.User.LastName, location = jsonLocation, history = locations }; return jsonTruckInfo; } return null; }
public void BinaryStressTest() { var b = new Truck("MAN"); var upper = Math.Pow(10, 3); var sw = new Stopwatch(); sw.Start(); b.LoadCargo(BinaryTestModels.ToList()); sw.Stop(); var secondElapsedToAdd = sw.ElapsedMilliseconds; Trace.WriteLine(string.Format("Put on the Channel {1} items. Time Elapsed: {0}", secondElapsedToAdd, upper)); sw.Reset(); sw.Start(); b.DeliverTo("Dad"); sw.Stop(); var secondElapsedToBroadcast = sw.ElapsedMilliseconds ; Trace.WriteLine(string.Format("Broadcast on the Channel {1} items. Time Elapsed: {0}", secondElapsedToBroadcast, upper)); var elem = b.UnStuffCargo<List<BinaryTestModel>>().First(); Assert.AreEqual(elem.Count(), 1000, "Not every elements have been broadcasted"); Assert.IsTrue(secondElapsedToAdd < 5000, "Add took more than 5 second. Review the logic, performance must be 10000 elems in less than 5 sec"); Assert.IsTrue(secondElapsedToBroadcast < 3000, "Broadcast took more than 3 second. Review the logic, performance must be 10000 elems in less than 5 sec"); }
private void Form1_Load(object sender, EventArgs e) { // initialize base map (for xServer internet) formsMap1.XMapUrl = "https://xmap-eu-n-test.cloud.ptvgroup.com/xmap/ws/XMap"; formsMap1.XMapCredentials = "xtok:561677741926322"; // go to Karlsruhe formsMap1.SetMapLocation(new Point(8.4, 49), 16); // add a new Shape Layer var layer = new ShapeLayer("MyShapes"); formsMap1.Layers.Add(layer); // create a truck marker var marker = new Truck { Color = Colors.Brown, Width = 50, ToolTip = "Hello Map" }; // set position and add to map ShapeCanvas.SetLocation(marker, new Point(8.4, 49)); layer.Shapes.Add(marker); }
public int AddTruck(DataService dataService, User user) { // Create the truck, driver, and route // Truck truck = new Truck { Name = TruckName, PlateNumber = TruckPlate, Type = TruckType, IsPrivate = IsPrivate, User = user }; IEnumerable<string> brokenRules; dataService.Trucks.Add(truck, out brokenRules); // Add the intial position of the truck // Location startLocation = new Location { Latitude = LatValue, Longitude = LngValue, Timestamp = DateTime.Now, Truck = truck }; dataService.Locations.Add(startLocation, out brokenRules); dataService.Commit(); return truck.Id; }
public void PrepareData() { ISession s = OpenSession(); ITransaction txn = s.BeginTransaction(); Car car = new Car(); car.Id = GetNewId(); car.Vin="123c"; car.Owner="Kirsten"; s.Save(car); Truck truck = new Truck(); truck.Id = GetNewId(); truck.Vin = "123t"; truck.Owner="Steve"; s.Save(truck); SUV suv = new SUV(); suv.Id = GetNewId(); suv.Vin = "123s"; suv.Owner="Joe"; s.Save(suv); Pickup pickup = new Pickup(); pickup.Id = GetNewId(); pickup.Vin = "123p"; pickup.Owner="Cecelia"; s.Save(pickup); txn.Commit(); s.Close(); }
public void TruckTest() { var t1 = new Truck(); var t2 = new Truck(); t1.size.Height = 2; t1.size.Width = 2; t2.size.Height = 3; t2.size.Width = 3; ComparisonResult result = _compare.Compare(t1, t2); Assert.IsFalse(result.AreEqual); var b1 = new Boxes(); var b2 = new Boxes(); b1.sizes = new List<Size>(); Size s1 = new Size(); s1.Height = 2; s1.Width = 2; b1.sizes.Add(s1); b2.sizes = new List<Size>(); Size s2 = new Size(); s2.Height = 3; s2.Width = 3; b1.sizes.Add(s2); result = _compare.Compare(b1, b2); Assert.IsFalse(result.AreEqual); }
public string Execute(ICommand command) { if (command.Name != "SetupPark" && this.VehiclePark == null) { return "The vehicle park has not been set up"; } switch (command.Name) { case "SetupPark": int sectors = int.Parse(command.Parameters["sectors"]); int placesPerSector = int.Parse(command.Parameters["placesPerSector"]); this.VehiclePark = new VehiclePark(sectors, placesPerSector); return "Vehicle park created"; case "Park": IVehicle vehicle = null; string licensePlate = command.Parameters["licensePlate"]; string owner = command.Parameters["owner"]; int reservedHours = int.Parse(command.Parameters["hours"]); int sector = int.Parse(command.Parameters["sector"]); int placeInSector = int.Parse(command.Parameters["place"]); DateTime timeOfEntry = DateTime.Parse(command.Parameters["time"], null, System.Globalization.DateTimeStyles.RoundtripKind); switch (command.Parameters["type"]) { case "car": vehicle = new Car(licensePlate, owner, reservedHours); break; case "motorbike": vehicle = new Motorbike(licensePlate, owner, reservedHours); break; case "truck": vehicle = new Truck(licensePlate, owner, reservedHours); break; } string result = this.VehiclePark.InsertVehicle(vehicle, sector, placeInSector, timeOfEntry); return result; case "Exit": string licensePlateExit = command.Parameters["licensePlate"]; DateTime timeOfEntryExit = DateTime.Parse(command.Parameters["time"], null, System.Globalization.DateTimeStyles.RoundtripKind); decimal amountPaid = decimal.Parse(command.Parameters["paid"]); // BUG: parameter name is "paid", not "money" string exitResult = this.VehiclePark.ExitVehicle(licensePlateExit, timeOfEntryExit, amountPaid); return exitResult; case "Status": return this.VehiclePark.GetStatus(); case "FindVehicle": return this.VehiclePark.FindVehicle(command.Parameters["licensePlate"]); case "VehiclesByOwner": return this.VehiclePark.FindVehiclesByOwner(command.Parameters["owner"]); default: throw new InvalidOperationException("Invalid command."); } }
public void Verify_LinekdList_String_Is_Not_Null_And_Has_2_Elements() { var bus = new Truck("GlobeTrotter"); bus.WaitDelivery("Mom").Wait(); var ret = bus.UnStuffCargo<LinkedList<string>>().First(); Assert.IsNotNull(ret); Assert.IsTrue(ret.Count == 2); }
protected bool Authorize(Truck truck, User user) { if (truck.User.Id != user.Id) { return false; } return true; }
protected bool FetchTruck(int truckId, out Truck truck) { truck = FetchTruck(truckId); if (truck == null) { return false; } return true; }
public void Verify_List_Int_Is_Not_Null_And_Has_5_Elements() { var bus = new Truck("GlobeTrotter"); bus.WaitDelivery("Mom").Wait(); var ret = bus.UnStuffCargo<List<int>>().First(); Assert.IsNotNull(ret); Assert.IsTrue(ret.Count == 5); }
public bool Add(Truck entity, out IEnumerable<string> brokenRules) { if(!_validation.IsValid(entity)) { brokenRules = _validation.BrokenRules(entity); return false; } brokenRules = null; return _truckRepo.Add(entity); }
// Use this for initialization void Start() { scoreUIObject = (GameObject)GameObject.Find ("ScoreUI"); scoreUIObject.GetComponent<Canvas> ().enabled = false; score = GameObject.Find ("Score"); scoreHandler = score.GetComponent<ScoreHandler>(); truck = GameObject.Find ("Truck").GetComponent<Truck> (); timeLeft = maxTime; loseScreen = false; winScreen = false; }
public static void BroadCastData(object target, Stream outgoingData) { Log.Configure("LINQBridgeVs", "DynamicCore"); try { var targetType = GetInterfaceTypeIfIsIterator(target); var targetTypeFullName = TypeNameHelper.GetDisplayName(targetType, true); var targetTypeName = TypeNameHelper.GetDisplayName(targetType, false); //I'm lazy I know it... var pattern1 = new Regex("[<]"); var pattern2 = new Regex("[>]"); var pattern3 = new Regex("[,]"); var pattern4 = new Regex("[`]"); var pattern5 = new Regex("[ ]"); var fileName = pattern1.Replace(targetTypeFullName, "("); fileName = pattern2.Replace(fileName, ")"); var typeName = pattern1.Replace(targetTypeName, string.Empty); typeName = pattern2.Replace(typeName, string.Empty); typeName = pattern3.Replace(typeName, string.Empty); typeName = pattern4.Replace(typeName, string.Empty); typeName = pattern5.Replace(typeName, string.Empty); fileName = TypeNameHelper.RemoveSystemNamespaces(fileName); var message = new Message { FileName = string.Format(FileNameFormat, fileName), TypeName = typeName.Trim(), TypeFullName = targetTypeFullName, //TypeLocation = GetAssemblyLocation(vsVersion, targetType.Name), TypeNamespace = targetType.Namespace, AssemblyQualifiedName = targetType.AssemblyQualifiedName }; var binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(outgoingData, message); Log.Write("BroadCastData to LINQBridgeVsTruck"); var truck = new Truck("LINQBridgeVsTruck"); truck.LoadCargo(target); var res = truck.DeliverTo(typeName); Log.Write("Data Succesfully Shipped to Grapple"); } catch (Exception e) { Log.Write(e, "Error in BroadCastData"); } }
public void TestPartialyFullPark() { IVehiclePark vehiclePark = new VehiclePark(1, 3); var firstVehicle = new Car("CA1001HH", "Jay Margareta", 1); vehiclePark.InsertCar(firstVehicle, 1, 1, new DateTime(2015, 05, 04, 10, 30, 00)); var thirdVehicle = new Truck("C5842CH", "Jessie Raul", 5); vehiclePark.InsertTruck(thirdVehicle, 1, 3, new DateTime(2015, 05, 04, 10, 50, 00)); string message = vehiclePark.GetStatus(); var result = new StringBuilder(); result.Append("Sector 1: 2 / 3 (67% full)"); Assert.AreEqual(result.ToString(), message); }
protected bool Authorize(int truckId, out User user, out Truck truck) { truck = null; if (!FetchUser(out user)) { return false; } if (!FetchTruck(truckId, out truck)) { _logger.Debug("No truck with id=" + truckId + " (" + user.UserName + ")"); return false; } return Authorize(truck, user); }
public void Init() { var bus = new Truck("GlobeTrotter"); var intList = new List<int> { 123, 12, 312, 312, 3 }; bus.LoadCargo(intList); var stringList = new List<string> { "asdasd", "asdasd123123" }; bus.LoadCargo(stringList); var linkedList = new LinkedList<string>(); linkedList.AddFirst(new LinkedListNode<string>("Hello")); linkedList.AddLast(new LinkedListNode<string>("World!")); bus.LoadCargo(linkedList); bus.DeliverTo("Mom"); }
static void Main(string[] args) { // adds functionality to a class // example: extention method // https://en.wikipedia.org/wiki/Visitor_pattern var vehicle = new Vehicle(); vehicle.Horn(); vehicle = new Car(); vehicle.Horn(); var car = new Car(); car.Horn(); var truck = new Truck(); truck.Horn(); Console.ReadLine(); }
private string ParkCommand(string type, string owner, string licensePlate, int reservedHours, int sector, int place, DateTime time) { switch (type) { case "car": var car = new Car(licensePlate, owner, reservedHours); return this.vehiclePark.InsertCar(car, sector, place, time); case "motorbike": var motorbike = new Motorbike(licensePlate, owner, reservedHours); return this.vehiclePark.InsertMotorbike(motorbike, sector, place, time); case "truck": var truck = new Truck(licensePlate, owner, reservedHours); return this.vehiclePark.InsertTruck(truck, sector, place, time); } return string.Empty; }
void button2_Click(object sender, EventArgs e) { // create a random geo-coordinate var rand = new Random(); var lat = rand.NextDouble() + 48.5; var lon = rand.NextDouble() + 8; // create a truck marker var marker = new Truck { Color = Color.FromRgb((byte)(rand.NextDouble() * 256), (byte)(rand.NextDouble() * 256), (byte)(rand.NextDouble() * 256)), Width = 20 + rand.NextDouble() * 20, ToolTip = "Hello Map" }; // set position and add to map ShapeCanvas.SetLocation(marker, new Point(lon, lat)); layer.Shapes.Add(marker); // set the location as center formsMap1.SetMapLocation(new Point(lon, lat), 10); }
public Vector2 stationTruck(Truck input) { Vector2 holder = new Vector2(); float yOff = 0; int x = 0; while(x < stationedTrucks.Length) { if(!stationedTrucksOccupied[x]) { stationedTrucksOccupied[x] = true; stationedTrucks[x] = input; break; } yOff -= yOffsetDelta; x++; } holder.x = holder.x + parkingOrigin.x + transform.position.x; holder.y = yOff + parkingOrigin.y + transform.position.y; return holder; }
public void Run() { //Added default values in car, truck and bus! for (int i = 0; i < 3; i++) { string[] inputVehicle = Console.ReadLine().Split(); string typeVehicle = inputVehicle[0]; double vehicleFuelQuantity = double.Parse(inputVehicle[1]); double vehicleFuelConsumption = double.Parse(inputVehicle[2]); double vehicleTankCapacity = double.Parse(inputVehicle[3]); if (typeVehicle == "Car") { car = new Car(vehicleFuelQuantity, vehicleFuelConsumption, vehicleTankCapacity); } else if (typeVehicle == "Truck") { truck = new Truck(vehicleFuelQuantity, vehicleFuelConsumption, vehicleTankCapacity); } else if (typeVehicle == "Bus") { bus = new Bus(vehicleFuelQuantity, vehicleFuelConsumption, vehicleTankCapacity); } } int countCommands = int.Parse(Console.ReadLine()); for (int i = 0; i < countCommands; i++) { try { string[] inputCommand = Console.ReadLine().Split(); string command = inputCommand[0]; string typeVehicle = inputCommand[1]; if (command == "Refuel") { double liters = double.Parse(inputCommand[2]); AddedRefuel(typeVehicle, liters); } else if (command == "Drive") { double distance = double.Parse(inputCommand[2]); CalcDistance(typeVehicle, distance); } else if (command == "DriveEmpty" && typeVehicle == "Bus") { double distance = double.Parse(inputCommand[2]); if (bus.AirConditioner() == "on") { bus.AirConditionerOff(); } Console.WriteLine(bus.Drive(distance)); } } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } } printRemainingFuel(); }
public ActionResult UpdateTruckInfo(int truckId, Truck truck) { User user; Truck truckOriginal; if(!Authorize(truckId, out user, out truckOriginal)) { return RedirectToAction("Index"); } truckOriginal.Name = truck.Name; truckOriginal.PlateNumber = truck.PlateNumber; truckOriginal.Type = truck.Type; truckOriginal.IsPrivate = truck.IsPrivate; IEnumerable<string> brokenRules; _dataService.Trucks.Update(truckOriginal, out brokenRules); _dataService.Commit(); Growl("Update - " + truckOriginal.Name, "The truck was successfully updated."); return RedirectToAction("Index"); }
private void ProcessViewItem(viewItem vItem) { Graphics3DImage graphics = InitializeImageFromViewParameters(vItem.viewParameters); // load case BoxProperties bProperties = LoadCaseById(null, _root.data.items.library_cases, vItem.itemId); if (null != bProperties) { graphics.AddBox(new Box(0, bProperties)); if (vItem.viewParameters.showDimensions) { graphics.AddDimensions(new DimensionCube(bProperties.Length, bProperties.Width, bProperties.Height)); } } // load pallet PalletProperties palletProperties = LoadPalletById(null, _root.data.items.library_pallets, vItem.itemId); if (null != palletProperties) { Pallet pallet = new Pallet(palletProperties); pallet.Draw(graphics, Transform3D.Identity); if (vItem.viewParameters.showDimensions) { graphics.AddDimensions(new DimensionCube(palletProperties.Length, palletProperties.Width, palletProperties.Height)); } } // load interlayer InterlayerProperties interlayerProperties = LoadInterlayerById(null, _root.data.items.library_interlayers, vItem.itemId); if (null != interlayerProperties) { graphics.AddBox(new Box(0, interlayerProperties)); if (vItem.viewParameters.showDimensions) { graphics.AddDimensions(new DimensionCube(interlayerProperties.Length, interlayerProperties.Width, interlayerProperties.Thickness)); } } // load bundle BundleProperties bundleProperties = LoadBundleById(null, _root.data.items.library_bundles, vItem.itemId); if (null != bundleProperties) { graphics.AddBox(new Box(0, bundleProperties)); if (vItem.viewParameters.showDimensions) { graphics.AddDimensions(new DimensionCube(bundleProperties.Length, bundleProperties.Width, bundleProperties.Height)); } } // load truck TruckProperties truckProperties = null; if (null != truckProperties) { Truck truck = new Truck(truckProperties); truck.Draw(graphics); if (vItem.viewParameters.showDimensions) { graphics.AddDimensions(new DimensionCube(truckProperties.Length, truckProperties.Width, truckProperties.Height)); } } FinalizeImageFromViewParameters(vItem.viewParameters, graphics); }
static void Main() { var sb = new StringBuilder(); IVehicle vehicle1 = null; IVehicle vehicle2 = null; IVehicle vehicle3 = null; var carData = Console.ReadLine().Split(); var fuelQuantity = double.Parse(carData[1]); var consum = double.Parse(carData[2]); var tankCapacity = double.Parse(carData[3]); if (fuelQuantity > tankCapacity) { //Console.WriteLine($"Cannot fit {fuelQuantity} fuel in the tank"); fuelQuantity = 0.0; } vehicle1 = new Car(fuelQuantity, consum, tankCapacity); var truckData = Console.ReadLine().Split(); fuelQuantity = double.Parse(truckData[1]); consum = double.Parse(truckData[2]); tankCapacity = double.Parse(truckData[3]); if (fuelQuantity > tankCapacity) { //Console.WriteLine($"Cannot fit {fuelQuantity} fuel in the tank"); fuelQuantity = 0.0; } vehicle2 = new Truck(fuelQuantity, consum, tankCapacity); var busData = Console.ReadLine().Split(); fuelQuantity = double.Parse(busData[1]); consum = double.Parse(busData[2]); tankCapacity = double.Parse(busData[3]); if (fuelQuantity > tankCapacity) { //Console.WriteLine($"Cannot fit {fuelQuantity} fuel in the tank"); fuelQuantity = 0.0; } vehicle3 = new Bus(fuelQuantity, consum, tankCapacity); var actionCounts = int.Parse(Console.ReadLine()); for (int index = 0; index < actionCounts; index++) { IVehicle vehicle = null; var commands = Console.ReadLine().Split(); var command = commands[0]; var type = commands[1]; var value = double.Parse(commands[2]); switch (type) { case "Car": vehicle = vehicle1; break; case "Truck": vehicle = vehicle2; break; case "Bus": vehicle = vehicle3; break; default: break; } switch (command) { case "Drive": vehicle.Drive(value); break; case "Refuel": vehicle.Refuel(value); break; case "DriveEmpty": vehicle.DriveEmpty(value); break; } } sb.AppendLine(vehicle1.ToString()) .AppendLine(vehicle2.ToString()) .AppendLine(vehicle3.ToString()); Console.WriteLine(sb.ToString()); }
static void Main() { string[] carInfo = Console.ReadLine().Split().ToArray(); double carFuelQuantity = double.Parse(carInfo[1]); double carFuelConsumption = double.Parse(carInfo[2]); double carTankCapacity = double.Parse(carInfo[3]); string[] truckInfo = Console.ReadLine().Split().ToArray(); double truckFuelQuantity = double.Parse(truckInfo[1]); double truckFuelConsumption = double.Parse(truckInfo[2]); double truckTankCapacity = double.Parse(truckInfo[3]); string[] busInfo = Console.ReadLine().Split().ToArray(); double busFuelQuantity = double.Parse(busInfo[1]); double busFuelConsumption = double.Parse(busInfo[2]); double busTankCapacity = double.Parse(busInfo[3]); var car = new Car(carFuelQuantity, carFuelConsumption, carTankCapacity); var truck = new Truck(truckFuelQuantity, truckFuelConsumption, truckTankCapacity); var bus = new Bus(busFuelQuantity, busFuelConsumption, busTankCapacity); int numberOfCommands = int.Parse(Console.ReadLine()); for (int i = 0; i < numberOfCommands; i++) { string[] commandInfo = Console.ReadLine().Split().ToArray(); string command = commandInfo[0]; string vehicleType = commandInfo[1]; if (command.Equals("Drive")) { double km = double.Parse(commandInfo[2]); if (vehicleType.Equals("Car")) { car.Drive(km); } else if (vehicleType.Equals("Truck")) { truck.Drive(km); } else if (vehicleType.Equals("Bus")) { bus.Drive(km); } } else if (command.Equals("DriveEmpty")) { double km = double.Parse(commandInfo[2]); bus.DriveEmpty(km); } else if (command.Equals("Refuel")) { double liters = double.Parse(commandInfo[2]); if (vehicleType.Equals("Car")) { car.Refuel(liters); } else if (vehicleType.Equals("Truck")) { truck.Refuel(liters); } else if (vehicleType.Equals("Bus")) { bus.Refuel(liters); } } } Console.WriteLine($"Car: {car.FuelQuantity:f2}"); Console.WriteLine($"Truck: {truck.FuelQuantity:f2}"); Console.WriteLine($"Bus: {bus.FuelQuantity:f2}"); }
public int GetGoal() { return(Truck.Goal()); }
public ActionResult RegisterDriver(RegisterDriverViewModel model) { if (ModelState.IsValid) { //Unqieness validations var checkEmailUniqueness = _context.Logins .SingleOrDefault(l => l.Email == model.Email); if (checkEmailUniqueness != null) { ModelState.AddModelError("Email", "Email id is already registered."); } var checkPhoneUnqiueness = _context.TruckOwners .SingleOrDefault(t => t.Phone == model.Phone); if (checkPhoneUnqiueness != null) { ModelState.AddModelError("Phone", "Phone number is already registered."); } var checkTruckUniqueness = _context.Trucks .SingleOrDefault(t => t.LicensePlate == model.LicensePlate); if (checkTruckUniqueness != null) { ModelState.AddModelError("LicensePlate", "Truck License Number is already registered."); } var checkDLNumberUniqueness = _context.TruckOwners .SingleOrDefault(t => t.DriverLicenseNumber == model.DriverLicenseNumber); if (checkDLNumberUniqueness != null) { ModelState.AddModelError("DriverLicenseNumber", "Driver License Number is already registered."); } var checkVRumberUniqueness = _context.TruckOwners .SingleOrDefault(t => t.VehicleRegNumber == model.VehicleRegNumber); if (checkVRumberUniqueness != null) { ModelState.AddModelError("VehicleRegNumber", "Vehicle Reg Number is already registered."); } var checkDIPNumberUniqueness = _context.TruckOwners .SingleOrDefault(t => t.DriverInsurancePolicy == model.DriverInsurancePolicy); if (checkDIPNumberUniqueness != null) { ModelState.AddModelError("DriverInsurancePolicy", "Driver Insurance Policy is already registered."); } //Unqieness validations if (checkEmailUniqueness == null && checkPhoneUnqiueness == null && checkTruckUniqueness == null && checkDLNumberUniqueness == null && checkVRumberUniqueness == null && checkDIPNumberUniqueness == null) { var salt = AuthenticationLogic.Get_SALT(64); var login = new Login { Email = model.Email.Trim(), Password = AuthenticationLogic.Get_HASH_SHA512(model.Password, model.Email, salt), PasswordSalt = salt, UserType = "D", EmailActivated = false, CreatedTime = DateTime.Now, ModifiedTime = DateTime.Now }; _context.Logins.Add(login); var truckOwner = new TruckOwner { FirstName = model.FirstName.Trim(), LastName = model.LastName.Trim(), Phone = model.Phone.Trim(), Email = model.Email.Trim(), CurrentStatusActive = false, Address1 = model.Address1.Trim(), Address2 = model.Address2, ZipCode = model.ZipCode.Trim(), City = model.City.Trim(), State = model.State.Trim(), DriverLicenseNumber = model.DriverLicenseNumber.Trim(), VehicleRegNumber = model.VehicleRegNumber.Trim(), DriverInsurancePolicy = model.DriverInsurancePolicy.Trim(), CreatedTime = DateTime.Now, ModifiedTime = DateTime.Now }; _context.TruckOwners.Add(truckOwner); var truck = new Truck { TruckOwnerId = truckOwner.TruckOwnerId, TruckTypeId = model.TruckTypeId, TruckMake = model.TruckMake.Trim(), TruckModel = model.TruckModel.Trim(), TruckYear = model.TruckYear.ToString(), LicensePlate = model.LicensePlate.Trim(), TruckColor = model.TruckColor.Trim(), CreatedTime = DateTime.Now, ModifiedTime = DateTime.Now }; _context.Trucks.Add(truck); _context.SaveChanges(); string token = truckOwner.TruckOwnerId + "c45kaa52165hrd84rd"; string verificationUrl = Url.Action("VerifyEmail", "TruckOwners", new { token = token }, Request.Url.Scheme); SendGridEmailService.SendEmailActivationLink("Driver", truckOwner.Email, truckOwner.FirstName, verificationUrl); TempData["ViewModel"] = new SuccessPageViewModel { Message = Constants.RegisterSuccessMessage }; return(RedirectToAction("Success", "Home")); } } model.TruckTypesList = GetTruckTypes(); return(View("../TruckOwners/BecomeDriver", model)); }
public void Run() { Car car = null; Truck truck = null; Bus bus = null; List <Vehicle> vehicles = new List <Vehicle>(); for (int i = 0; i < 3; i++) { string[] vehicleArgs = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries); string type = vehicleArgs[0]; double fuelQuantity = double.Parse(vehicleArgs[1]); double consumption = double.Parse(vehicleArgs[2]); double capacity = double.Parse(vehicleArgs[3]); if (type == "Car") { car = new Car(fuelQuantity, consumption, capacity); vehicles.Add(car); } else if (type == "Truck") { truck = new Truck(fuelQuantity, consumption, capacity); vehicles.Add(truck); } else if (type == "Bus") { bus = new Bus(fuelQuantity, consumption, capacity); vehicles.Add(bus); } } int lines = int.Parse(Console.ReadLine()); for (int i = 0; i < lines; i++) { try { string[] actions = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries); string action = actions[0]; string type = actions[1]; double value = double.Parse(actions[2]); if (type == "Car") { if (action == "Drive") { Console.WriteLine(car.Drive(value)); } else if (action == "Refuel") { car.Refuel(value); } } else if (type == "Truck") { if (action == "Drive") { Console.WriteLine(truck.Drive(value)); } else if (action == "Refuel") { truck.Refuel(value); } } else if (type == "Bus") { if (action == "Drive") { Console.WriteLine(bus.Drive(value)); } else if (action == "DriveEmpty") { Console.WriteLine(bus.DriveEmpty(value)); } else if (action == "Refuel") { bus.Refuel(value); } } } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } catch (InvalidFuelArgument ifa) { Console.WriteLine(ifa.Message); } } foreach (var vehicle in vehicles) { Console.WriteLine(vehicle); } }
static void Main() { var carInfo = Console.ReadLine().Split(); Vehicle car = new Car(double.Parse(carInfo[1]), double.Parse(carInfo[2]), double.Parse(carInfo[3])); var truckInfo = Console.ReadLine().Split(); Vehicle truck = new Truck(double.Parse(truckInfo[1]), double.Parse(truckInfo[2]), double.Parse(truckInfo[3])); var busInfo = Console.ReadLine().Split(); Vehicle bus = new Bus(double.Parse(busInfo[1]), double.Parse(busInfo[2]), double.Parse(busInfo[3])); var countOfCommands = int.Parse(Console.ReadLine()); for (int i = 0; i < countOfCommands; i++) { var commandArgs = Console.ReadLine().Split(); var command = commandArgs[0]; var typeOfVehicle = commandArgs[1]; var givenParam = double.Parse(commandArgs[2]); Vehicle vehicleToOperate; if (typeOfVehicle == "Car") { vehicleToOperate = car; } else if (typeOfVehicle == "Truck") { vehicleToOperate = truck; } else { vehicleToOperate = bus; } try { switch (command) { case "Drive": vehicleToOperate.Drive(givenParam); Console.WriteLine($"{vehicleToOperate.GetType().Name} travelled {givenParam} km"); break; case "DriveEmpty": ((Bus)vehicleToOperate).DriveEmpty(givenParam); Console.WriteLine($"{vehicleToOperate.GetType().Name} travelled {givenParam} km"); break; case "Refuel": vehicleToOperate.Refuel(givenParam); break; } } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.WriteLine(car); Console.WriteLine(truck); Console.WriteLine(bus); }
private static void displayAllDetailsOfVehicle(string i_LicensePlateNumber, Garage i_Garage) { VehicleInGarage requestedVehicle = i_Garage.SearchForVehicleInGarage(i_LicensePlateNumber); if (requestedVehicle != null) { string status = requestedVehicle.GetVehicleStatusInString(); bool isFuelEngine = requestedVehicle.TheVehicle.VehicleEngine is FuelEngine; bool isCar = requestedVehicle.TheVehicle is Car; bool isMotorCycle = requestedVehicle.TheVehicle is Motorcycle; Console.WriteLine( @"License plate number is: {0} Model name: {1} Owners name: {2} Owners Phone number: {3} Vehicle status: {4}", requestedVehicle.TheVehicle.LicensePlateNumber, requestedVehicle.TheVehicle.ModelName, requestedVehicle.OwnersName, requestedVehicle.OwnnersPhoneNumber, status); displayWheelsDetails(requestedVehicle.TheVehicle.VehicleWheels); if (isFuelEngine) { FuelEngine vehicleEngine = requestedVehicle.TheVehicle.VehicleEngine as FuelEngine; Console.WriteLine( @"Current Amount of fuel: {0} Fuel Type: {1}", requestedVehicle.TheVehicle.VehicleEngine.CurrentAmountOfEnergy, vehicleEngine.GetFuelTypeInString()); } else { ElectricEngine vehicleEngine = requestedVehicle.TheVehicle.VehicleEngine as ElectricEngine; if (vehicleEngine != null) { Console.WriteLine( @"Time left in battery: {0}", vehicleEngine.CurrentAmountOfEnergy); } } if (isCar) { Car vehicleType = requestedVehicle.TheVehicle as Car; if (vehicleType != null) { Console.WriteLine( @"Color: {0} Number Of Doors: {1}", vehicleType.GetColorInString(), (int)vehicleType.NumbersOfDoors); } } else if (isMotorCycle) { Motorcycle vehicleType = requestedVehicle.TheVehicle as Motorcycle; if (vehicleType != null) { Console.WriteLine( @"License Type: {0} Engine volume: {1}", vehicleType.GetLicenseTypeInString(), vehicleType.EngineVolume); } } else { Truck vehicleType = requestedVehicle.TheVehicle as Truck; if (vehicleType != null) { string isCooled = "No"; if (vehicleType.IsTrankCooled) { isCooled = "YES"; } Console.WriteLine( @"Is trunk cooled: {0} Trunk volume: {1}", isCooled, vehicleType.TrankVolume); } } } else { Console.WriteLine("vehicle not found"); } }
public ITruckPackage LoadTruck(Truck truck) { var packager = GetPackager(_configuration.Strategy); return(packager.PackTruck(truck)); }
public static string getOutputString(Truck truck) { return(getVehicleOutputString(truck) + $"{truck.Axis} Achsen, {truck.Payload} t, "); }
static void Main(string[] args) { var CarData = Console.ReadLine().Split(); var car = new Car(double.Parse(CarData[1]), double.Parse(CarData[2]), CarAirCondConsumption, double.Parse(CarData[3])); var TruckData = Console.ReadLine().Split(); var truck = new Truck(double.Parse(TruckData[1]), double.Parse(TruckData[2]), TruckAirCondConsumption, double.Parse(CarData[3])); var BusData = Console.ReadLine().Split(); var bus = new Bus(double.Parse(TruckData[1]), double.Parse(TruckData[2]), TruckAirCondConsumption, double.Parse(CarData[3])); int numberOfCommands = int.Parse(Console.ReadLine()); while (numberOfCommands > 0) { var command = Console.ReadLine().Split(); var action = command[0]; var vehicleType = command[1]; var vehicleData = double.Parse(command[2]); try { switch (action) { case "Drive": if (vehicleType == "car") { car.Driving(vehicleData); } else { truck.Driving(vehicleData); } break; case "Refuel": if (vehicleType == "truck") { truck.Refuel(vehicleData); } else { car.Refuel(vehicleData); } break; case "DriveEmpty": bus.Driving(vehicleData); break; default: break; } numberOfCommands--; Console.WriteLine(car); Console.WriteLine(truck); Console.WriteLine(bus); } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } } }
private static void ExecuteCommands(Car car, Truck truck, Bus bus) { var numberOfCommands = int.Parse(Console.ReadLine()); while (numberOfCommands > 0) { numberOfCommands--; var command = Console.ReadLine().Split(); var action = command[0]; var vehicleType = command[1]; var value = double.Parse(command[2]); try { switch (action) { case "Drive": Console.WriteLine(vehicleType == "Car" ? car.Drive(value) : vehicleType == "Truck" ? truck.Drive(value) : bus.Drive(value)); break; case "Refuel": switch (vehicleType) { case "Car": car.Refuel(value); break; case "Truck": truck.Refuel(value); break; case "Bus": bus.Refuel(value); break; default: break; } break; case "DriveEmpty": bus.IsAirConditionerTurnedOn = false; Console.WriteLine(bus.Drive(value)); bus.IsAirConditionerTurnedOn = true; break; default: break; } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } } }
// Use this for initialization void Awake() { cargoObject = GameObject.Find ("NewCrane"); cargoBag = cargoObject.GetComponent<CargoBag>(); missionWinObject = GameObject.Find ("MissionWinUI"); missionWinUI = missionWinObject.GetComponent<MissionWinUI>(); //fields timeObject = GameObject.Find ("Time"); time = timeObject.GetComponent<Text>(); levelObject = GameObject.Find ("Level"); level = levelObject.GetComponent<Text>(); nextObject = GameObject.Find ("Next"); next = nextObject.GetComponent<Text>(); woodObject = GameObject.Find ("Wood"); wood = woodObject.GetComponent<Text> (); ironObject = GameObject.Find ("Iron"); iron = ironObject.GetComponent<Text>(); glassObject = GameObject.Find ("Glass"); glass = glassObject.GetComponent<Text>(); glassLabelObject = GameObject.Find ("GlassLabel"); glassLabel = glassLabelObject.GetComponent<Text>(); cargoImageObject = GameObject.Find ("CargoImage"); cargoImage = cargoImageObject.GetComponent<Image>(); truck = GameObject.Find ("Truck").GetComponent<Truck> (); timeLeft = maxTime; tutorialObject = GameObject.Find ("Tutorial"); level.text = (Application.loadedLevel).ToString(); }
public async Task <IHttpActionResult> Insert([FromBody] Truck body) { await _rep.Insert(body); return(Ok()); }
public string InsertTruck(Truck truck, int sector, int place, DateTime time) { var message = this.InsertVehicle(truck, sector, place, time); return message; }
static void Main() { List <Car> carCatalog = new List <Car>(); List <Truck> truckCatalog = new List <Truck>(); double carsTotalPower = 0; double trucksTotalPower = 0; while (true) { string input = Console.ReadLine(); if (input == "End") { break; } string[] split = input.Split(); string type = split[0]; string model = split[1]; string color = split[2]; int power = int.Parse(split[3]); if (type == "car") { Car newCar = new Car(model, color, power); carCatalog.Add(newCar); carsTotalPower += newCar.HorsePower; } else { Truck newTruck = new Truck(model, color, power); truckCatalog.Add(newTruck); trucksTotalPower += newTruck.HorsePower; } } while (true) { string vehicleModel = Console.ReadLine(); if (vehicleModel == "Close the Catalogue") { break; } if (carCatalog.Any(x => x.Model == vehicleModel)) { foreach (Car item in carCatalog.Where(x => x.Model == vehicleModel)) { Console.WriteLine("Type: Car"); Console.WriteLine($"Model: {item.Model}"); Console.WriteLine($"Color: {item.Color}"); Console.WriteLine($"Horsepower: {item.HorsePower}"); } } else if (truckCatalog.Any(x => x.Model == vehicleModel)) { foreach (Truck item in truckCatalog.Where(x => x.Model == vehicleModel)) { Console.WriteLine("Type: Truck"); Console.WriteLine($"Model: {item.Model}"); Console.WriteLine($"Color: {item.Color}"); Console.WriteLine($"Horsepower: {item.HorsePower}"); } } } if (carCatalog.Count <= 0 && truckCatalog.Count > 0) { Console.WriteLine($"Cars have average horsepower of: {0:f2}."); Console.WriteLine($"Trucks have average horsepower of: {trucksTotalPower / truckCatalog.Count:F2}."); } else if (carCatalog.Count > 0 && truckCatalog.Count <= 0) { Console.WriteLine($"Cars have average horsepower of: {carsTotalPower / carCatalog.Count:F2}."); Console.WriteLine($"Trucks have average horsepower of: {0:f2}."); } else if (carCatalog.Count <= 0 && truckCatalog.Count <= 0) { Console.WriteLine($"Cars have average horsepower of: {0:f2}."); Console.WriteLine($"Trucks have average horsepower of: {0:f2}."); } else { Console.WriteLine($"Cars have average horsepower of: {carsTotalPower / carCatalog.Count:F2}."); Console.WriteLine($"Trucks have average horsepower of: {trucksTotalPower / truckCatalog.Count:F2}."); } }
/// <summary> /// Create a new Truck object. /// </summary> /// <param name="ID">Initial value of Id.</param> /// <param name="make">Initial value of Make.</param> /// <param name="model">Initial value of Model.</param> /// <param name="year">Initial value of Year.</param> public static Truck CreateTruck(int ID, string make, string model, int year) { Truck truck = new Truck(); truck.Id = ID; truck.Make = make; truck.Model = model; truck.Year = year; return truck; }
public void Prepare() { ISession s = tc.OpenNewSession(); ITransaction txn = s.BeginTransaction(); Polliwog = new Animal {BodyWeight = 12, Description = "Polliwog"}; Catepillar = new Animal {BodyWeight = 10, Description = "Catepillar"}; Frog = new Animal {BodyWeight = 34, Description = "Frog"}; Polliwog.Father = Frog; Frog.AddOffspring(Polliwog); Butterfly = new Animal {BodyWeight = 9, Description = "Butterfly"}; Catepillar.Mother = Butterfly; Butterfly.AddOffspring(Catepillar); s.Save(Frog); s.Save(Polliwog); s.Save(Butterfly); s.Save(Catepillar); var dog = new Dog {BodyWeight = 200, Description = "dog"}; s.Save(dog); var cat = new Cat {BodyWeight = 100, Description = "cat"}; s.Save(cat); Zoo = new Zoo {Name = "Zoo"}; var add = new Address {City = "MEL", Country = "AU", Street = "Main st", PostalCode = "3000"}; Zoo.Address = add; PettingZoo = new PettingZoo {Name = "Petting Zoo"}; var addr = new Address {City = "Sydney", Country = "AU", Street = "High st", PostalCode = "2000"}; PettingZoo.Address = addr; s.Save(Zoo); s.Save(PettingZoo); var joiner = new Joiner {JoinedName = "joined-name", Name = "name"}; s.Save(joiner); var car = new Car {Vin = "123c", Owner = "Kirsten"}; s.Save(car); var truck = new Truck {Vin = "123t", Owner = "Steve"}; s.Save(truck); var suv = new SUV {Vin = "123s", Owner = "Joe"}; s.Save(suv); var pickup = new Pickup {Vin = "123p", Owner = "Cecelia"}; s.Save(pickup); var b = new BooleanLiteralEntity(); s.Save(b); txn.Commit(); s.Close(); }
public static void Main() { string[] carInfo = Console.ReadLine().Split(); Vehicle car = new Car(double.Parse(carInfo[1]), double.Parse(carInfo[2]), double.Parse(carInfo[3])); string[] truckInfo = Console.ReadLine().Split(); Vehicle truck = new Truck(double.Parse(truckInfo[1]), double.Parse(truckInfo[2]), double.Parse(truckInfo[3])); string[] busInfo = Console.ReadLine().Split(); Vehicle bus = new Bus(double.Parse(busInfo[1]), double.Parse(busInfo[2]) + 1.4, double.Parse(busInfo[3])); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string[] tokens = Console.ReadLine().Split(); if (tokens[0] == "Drive") { double kilometers = double.Parse(tokens[2]); switch (tokens[1]) { case "Car": car.DistanceToMove = kilometers; car.Drive(car, tokens[1]); break; case "Truck": truck.DistanceToMove = kilometers; truck.Drive(truck, tokens[1]); break; case "Bus": bus.DistanceToMove = kilometers; bus.Drive(bus, tokens[1]); break; } } else if (tokens[0] == "Refuel") { double litters = double.Parse(tokens[2]); switch (tokens[1]) { case "Car": car.Refuel(car, litters); break; case "Truck": truck.Refuel(truck, litters); break; case "Bus": bus.Refuel(bus, litters); break; } } else if (tokens[0] == "DriveEmpty") { bus.DistanceToMove = double.Parse(tokens[2]); bus.LittersPerKm -= 1.4; bus.Drive(bus, "Bus"); } } Console.WriteLine($"Car: {car.FuelQnty:F2}"); Console.WriteLine($"Truck: {truck.FuelQnty:F2}"); Console.WriteLine($"Bus: {bus.FuelQnty:F2}"); }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new EFCContext(serviceProvider.GetRequiredService <DbContextOptions <EFCContext> >())) { if (context.Truck.Any()) { return; } //seeding REGIONS var regions = new Region [] { new Region { RegionLabel = "Davidson" // stops 1-6, stop 0 also here - where the refill events occur }, new Region { RegionLabel = "Sumner" // stops 7-12 }, new Region { RegionLabel = "Wilson" // stops 13-18 }, new Region { RegionLabel = "Rutherford" // stops 19-24 }, new Region { RegionLabel = "Williamson" // stops 25-30 }, new Region { RegionLabel = "Cheatham" // stops 31-36 }, new Region { RegionLabel = "Robertson" // stops 37-42 } }; foreach (Region i in regions) { context.Region.Add(i); } context.SaveChanges(); //seeding STOPS var stops = new Stop [] // six stops per region following the refill stop, so 43 in total over 6 regions { new Stop { RegionId = regions.Single(n => n.RegionLabel == "Davidson").RegionId, StopLabel = "Refill" // stop 0 is a refill at the refill station in region 0 }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Davidson").RegionId, StopLabel = "Alpha" // random names here from phonetic alphabet }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Davidson").RegionId, StopLabel = "Bravo" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Davidson").RegionId, StopLabel = "Charlie" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Davidson").RegionId, StopLabel = "Delta" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Davidson").RegionId, StopLabel = "Echo" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Davidson").RegionId, StopLabel = "Foxtrot" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Sumner").RegionId, // 7 StopLabel = "Golf" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Sumner").RegionId, StopLabel = "Hotel" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Sumner").RegionId, StopLabel = "India" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Sumner").RegionId, StopLabel = "Juliet" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Sumner").RegionId, StopLabel = "Kilo" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Sumner").RegionId, StopLabel = "Lima" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Wilson").RegionId, // 13 StopLabel = "Mike" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Wilson").RegionId, StopLabel = "November" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Wilson").RegionId, StopLabel = "Oscar" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Wilson").RegionId, StopLabel = "Papa" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Wilson").RegionId, StopLabel = "Quebec" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Wilson").RegionId, StopLabel = "Romeo" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Rutherford").RegionId, // 19 StopLabel = "Sierra" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Rutherford").RegionId, StopLabel = "Tango" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Rutherford").RegionId, StopLabel = "Uniform" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Rutherford").RegionId, StopLabel = "Victor" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Rutherford").RegionId, StopLabel = "Whiskey" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Rutherford").RegionId, StopLabel = "Xray" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Williamson").RegionId, // 25 StopLabel = "Yankee" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Williamson").RegionId, StopLabel = "Zulu" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Williamson").RegionId, StopLabel = "Alexander" // random names from here based on most common boy names from 2012 }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Williamson").RegionId, StopLabel = "Benjamin" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Williamson").RegionId, StopLabel = "Christopher" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Williamson").RegionId, StopLabel = "Daniel" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Cheatham").RegionId, // 31 StopLabel = "Ethan" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Cheatham").RegionId, StopLabel = "Fernando" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Cheatham").RegionId, StopLabel = "Gabriel" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Cheatham").RegionId, StopLabel = "Henry" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Cheatham").RegionId, StopLabel = "Isaac" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Cheatham").RegionId, StopLabel = "Jacob" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Robertson").RegionId, // 37 StopLabel = "Kevin" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Robertson").RegionId, StopLabel = "Liam" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Robertson").RegionId, StopLabel = "Mason" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Robertson").RegionId, StopLabel = "Noah" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Robertson").RegionId, StopLabel = "Owen" }, new Stop { RegionId = regions.Single(n => n.RegionLabel == "Robertson").RegionId, StopLabel = "Parker" } }; foreach (Stop i in stops) { context.Stop.Add(i); } context.SaveChanges(); //seeding FUEL EVENTS var fuelEvents = new FuelEvent [] { new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Alpha").StopId, FuelPercentageChange = -17, // difference between current truck fuel level and 100%, in this case arbitrary FuelTimeStamp = new DateTime(2017, 9, 28, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Alpha").StopId, FuelPercentageChange = -16, // generate random number between -5 and -17 to determine fuel depletion amount of truck FuelTimeStamp = new DateTime(2017, 9, 18, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Alpha").StopId, FuelPercentageChange = -15, FuelTimeStamp = new DateTime(2017, 9, 8, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Bravo").StopId, FuelPercentageChange = -10, FuelTimeStamp = new DateTime(2017, 9, 8, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Bravo").StopId, FuelPercentageChange = -9, FuelTimeStamp = new DateTime(2017, 9, 18, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Bravo").StopId, FuelPercentageChange = -8, FuelTimeStamp = new DateTime(2017, 9, 28, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Charlie").StopId, FuelPercentageChange = -6, FuelTimeStamp = new DateTime(2017, 9, 8, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Charlie").StopId, FuelPercentageChange = -7, FuelTimeStamp = new DateTime(2017, 9, 18, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Charlie").StopId, FuelPercentageChange = -8, FuelTimeStamp = new DateTime(2017, 9, 28, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Delta").StopId, FuelPercentageChange = -7, FuelTimeStamp = new DateTime(2017, 9, 8, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Delta").StopId, FuelPercentageChange = -12, FuelTimeStamp = new DateTime(2017, 9, 18, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Delta").StopId, FuelPercentageChange = -6, FuelTimeStamp = new DateTime(2017, 9, 28, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Alpha").StopId, FuelPercentageChange = -17, // difference between current truck fuel level and 100%, in this case arbitrary FuelTimeStamp = new DateTime(2017, 8, 28, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Bravo").StopId, FuelPercentageChange = -5, FuelTimeStamp = new DateTime(2017, 8, 18, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Charlie").StopId, FuelPercentageChange = -6, FuelTimeStamp = new DateTime(2017, 8, 8, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Delta").StopId, FuelPercentageChange = -7, FuelTimeStamp = new DateTime(2017, 7, 28, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Echo").StopId, FuelPercentageChange = -8, FuelTimeStamp = new DateTime(2017, 7, 18, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Foxtrot").StopId, FuelPercentageChange = -9, FuelTimeStamp = new DateTime(2017, 7, 8, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Golf").StopId, FuelPercentageChange = -10, FuelTimeStamp = new DateTime(2017, 6, 28, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Hotel").StopId, FuelPercentageChange = -11, FuelTimeStamp = new DateTime(2017, 6, 18, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "India").StopId, FuelPercentageChange = -12, FuelTimeStamp = new DateTime(2017, 6, 8, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Juliet").StopId, FuelPercentageChange = -13, FuelTimeStamp = new DateTime(2017, 5, 28, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Kilo").StopId, FuelPercentageChange = -14, FuelTimeStamp = new DateTime(2017, 5, 18, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Lima").StopId, FuelPercentageChange = -15, FuelTimeStamp = new DateTime(2017, 5, 8, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Mike").StopId, FuelPercentageChange = -16, FuelTimeStamp = new DateTime(2017, 4, 28, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "November").StopId, FuelPercentageChange = -17, FuelTimeStamp = new DateTime(2017, 4, 18, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Oscar").StopId, FuelPercentageChange = -5, FuelTimeStamp = new DateTime(2017, 4, 8, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Papa").StopId, FuelPercentageChange = -6, FuelTimeStamp = new DateTime(2017, 3, 28, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Quebec").StopId, FuelPercentageChange = -7, FuelTimeStamp = new DateTime(2017, 3, 18, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Romeo").StopId, FuelPercentageChange = -8, FuelTimeStamp = new DateTime(2017, 3, 8, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Sierra").StopId, FuelPercentageChange = -9, FuelTimeStamp = new DateTime(2017, 2, 28, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Tango").StopId, FuelPercentageChange = -10, FuelTimeStamp = new DateTime(2017, 2, 18, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Uniform").StopId, FuelPercentageChange = -11, FuelTimeStamp = new DateTime(2017, 2, 8, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Victor").StopId, FuelPercentageChange = -12, FuelTimeStamp = new DateTime(2017, 1, 28, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Whiskey").StopId, FuelPercentageChange = -13, FuelTimeStamp = new DateTime(2017, 1, 18, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Xray").StopId, FuelPercentageChange = -14, FuelTimeStamp = new DateTime(2017, 1, 8, 2, 3, 0) }, new FuelEvent { StopId = stops.Single(n => n.StopLabel == "Yankee").StopId, FuelPercentageChange = -15, FuelTimeStamp = new DateTime(2016, 12, 28, 2, 3, 0) } }; foreach (FuelEvent i in fuelEvents) { context.FuelEvent.Add(i); } context.SaveChanges(); //seeding TRUCKS var trucks = new Truck [] { new Truck { CurrentFuelLevel = 100, // each truck starting the day with 100% fuel from Davidson truck yard CurrentStopId = stops.Single(n => n.StopLabel == "Alpha").StopId, // Stop 0 is refill in region 0 NextStopId = stops.Single(n => n.StopLabel == "Alpha").StopId, // RegionId = regions.Single(n => n.RegionLabel == "Davidson").RegionId }, new Truck { CurrentFuelLevel = 99, CurrentStopId = stops.Single(n => n.StopLabel == "Alpha").StopId, NextStopId = stops.Single(n => n.StopLabel == "Golf").StopId, RegionId = regions.Single(n => n.RegionLabel == "Sumner").RegionId }, new Truck { CurrentFuelLevel = 98, CurrentStopId = stops.Single(n => n.StopLabel == "Alpha").StopId, NextStopId = stops.Single(n => n.StopLabel == "Mike").StopId, RegionId = regions.Single(n => n.RegionLabel == "Wilson").RegionId }, new Truck { CurrentFuelLevel = 97, CurrentStopId = stops.Single(n => n.StopLabel == "Alpha").StopId, NextStopId = stops.Single(n => n.StopLabel == "Sierra").StopId, RegionId = regions.Single(n => n.RegionLabel == "Rutherford").RegionId }, new Truck { CurrentFuelLevel = 96, CurrentStopId = stops.Single(n => n.StopLabel == "Alpha").StopId, NextStopId = stops.Single(n => n.StopLabel == "Yankee").StopId, RegionId = regions.Single(n => n.RegionLabel == "Williamson").RegionId }, new Truck { CurrentFuelLevel = 95, CurrentStopId = stops.Single(n => n.StopLabel == "Alpha").StopId, NextStopId = stops.Single(n => n.StopLabel == "Ethan").StopId, RegionId = regions.Single(n => n.RegionLabel == "Cheatham").RegionId }, new Truck { CurrentFuelLevel = 94, CurrentStopId = stops.Single(n => n.StopLabel == "Alpha").StopId, NextStopId = stops.Single(n => n.StopLabel == "Kevin").StopId, RegionId = regions.Single(n => n.RegionLabel == "Robertson").RegionId } }; foreach (Truck i in trucks) { context.Truck.Add(i); } context.SaveChanges(); //seeding DISPATCH EVENTS var dispatchEvents = new DispatchEvent [] { new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 100).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Refill").StopId, DispatchTimeStamp = new DateTime(2017, 8, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 100).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Alpha").StopId, DispatchTimeStamp = new DateTime(2017, 8, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 100).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Bravo").StopId, DispatchTimeStamp = new DateTime(2017, 8, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 100).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Charlie").StopId, DispatchTimeStamp = new DateTime(2017, 7, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 100).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Delta").StopId, DispatchTimeStamp = new DateTime(2017, 7, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 100).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Echo").StopId, DispatchTimeStamp = new DateTime(2017, 7, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 99).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Refill").StopId, DispatchTimeStamp = new DateTime(2017, 6, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 99).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Foxtrot").StopId, DispatchTimeStamp = new DateTime(2017, 6, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 99).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Golf").StopId, DispatchTimeStamp = new DateTime(2017, 6, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 99).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Hotel").StopId, DispatchTimeStamp = new DateTime(2017, 5, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 99).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "India").StopId, DispatchTimeStamp = new DateTime(2017, 5, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 99).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Juliet").StopId, DispatchTimeStamp = new DateTime(2017, 5, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 99).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Kilo").StopId, DispatchTimeStamp = new DateTime(2017, 4, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 98).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Refill").StopId, DispatchTimeStamp = new DateTime(2017, 4, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 98).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Lima").StopId, DispatchTimeStamp = new DateTime(2017, 4, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 98).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Mike").StopId, DispatchTimeStamp = new DateTime(2017, 3, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 98).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "November").StopId, DispatchTimeStamp = new DateTime(2017, 3, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 98).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Oscar").StopId, DispatchTimeStamp = new DateTime(2017, 3, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 98).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Papa").StopId, DispatchTimeStamp = new DateTime(2017, 3, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 98).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Quebec").StopId, DispatchTimeStamp = new DateTime(2017, 3, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 97).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Refill").StopId, DispatchTimeStamp = new DateTime(2017, 2, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 97).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Romeo").StopId, DispatchTimeStamp = new DateTime(2017, 2, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 97).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Sierra").StopId, DispatchTimeStamp = new DateTime(2017, 2, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 97).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Tango").StopId, DispatchTimeStamp = new DateTime(2017, 1, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 97).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Uniform").StopId, DispatchTimeStamp = new DateTime(2017, 1, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 97).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Victor").StopId, DispatchTimeStamp = new DateTime(2017, 1, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 97).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Whiskey").StopId, DispatchTimeStamp = new DateTime(2016, 12, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 96).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Refill").StopId, DispatchTimeStamp = new DateTime(2016, 12, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 96).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Xray").StopId, DispatchTimeStamp = new DateTime(2016, 12, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 96).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Yankee").StopId, DispatchTimeStamp = new DateTime(2016, 11, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 96).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Zulu").StopId, DispatchTimeStamp = new DateTime(2016, 11, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 96).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Alexander").StopId, DispatchTimeStamp = new DateTime(2016, 11, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 96).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Benjamin").StopId, DispatchTimeStamp = new DateTime(2016, 10, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 96).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Christopher").StopId, DispatchTimeStamp = new DateTime(2016, 10, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 95).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Refill").StopId, DispatchTimeStamp = new DateTime(2016, 10, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 95).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Daniel").StopId, DispatchTimeStamp = new DateTime(2016, 9, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 95).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Ethan").StopId, DispatchTimeStamp = new DateTime(2016, 9, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 95).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Fernando").StopId, DispatchTimeStamp = new DateTime(2016, 9, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 95).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Gabriel").StopId, DispatchTimeStamp = new DateTime(2016, 8, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 95).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Isaac").StopId, DispatchTimeStamp = new DateTime(2016, 8, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 95).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Jacob").StopId, DispatchTimeStamp = new DateTime(2016, 8, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 94).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Refill").StopId, DispatchTimeStamp = new DateTime(2016, 7, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 94).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Kevin").StopId, DispatchTimeStamp = new DateTime(2016, 7, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 94).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Liam").StopId, DispatchTimeStamp = new DateTime(2016, 7, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 94).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Mason").StopId, DispatchTimeStamp = new DateTime(2016, 6, 28, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 94).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Noah").StopId, DispatchTimeStamp = new DateTime(2016, 6, 18, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 94).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Owen").StopId, DispatchTimeStamp = new DateTime(2016, 6, 8, 1, 3, 0) }, new DispatchEvent { TruckTargetId = trucks.Single(n => n.CurrentFuelLevel == 94).TruckId, SetNextStopId = stops.Single(n => n.StopLabel == "Parker").StopId, DispatchTimeStamp = new DateTime(2016, 5, 28, 1, 3, 0) } }; foreach (DispatchEvent i in dispatchEvents) { context.DispatchEvent.Add(i); } context.SaveChanges(); } }
static void Main(string[] args) { string[] carInfo = Console.ReadLine().Split(); string[] truckInfo = Console.ReadLine().Split(); string[] busInfo = Console.ReadLine().Split(); List <Vehicles> vehicles = new List <Vehicles>(); Car car = new Car(double.Parse(carInfo[1]), double.Parse(carInfo[2]), double.Parse(carInfo[3])); Truck truck = new Truck(double.Parse(truckInfo[1]), double.Parse(truckInfo[2]), double.Parse(truckInfo[3])); Bus bus = new Bus(double.Parse(busInfo[1]), double.Parse(busInfo[2]), double.Parse(busInfo[3])); vehicles.Add(car); vehicles.Add(truck); vehicles.Add(bus); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string[] input = Console.ReadLine().Split(); try { switch (input[0]) { case "Drive": if (input[1] == "Car") { Console.WriteLine(vehicles.Find(x => x.GetType().Name == "Car").VehicleTravelled( double.Parse(input[2]), "Car", 0.9)); } else if (input[1] == "Truck") { Console.WriteLine(vehicles.Find(x => x.GetType().Name == "Truck").VehicleTravelled( double.Parse(input[2]), "Truck", 1.6)); } else if (input[1] == "Bus") { Console.WriteLine(vehicles.Find(x => x.GetType().Name == "Bus").VehicleTravelled( double.Parse(input[2]), "Bus", 1.4)); } break; case "DriveEmpty": if (input[1] == "Bus") { Console.WriteLine(vehicles.Find(x => x.GetType().Name == "Bus").VehicleTravelled( double.Parse(input[2]), "Bus", 0)); } break; case "Refuel": if (input[1] == "Car") { vehicles.Find(x => x.GetType().Name == "Car").VehicleRefueling( double.Parse(input[2]), "Car", 1); } else if (input[1] == "Truck") { vehicles.Find(x => x.GetType().Name == "Truck").VehicleRefueling( double.Parse(input[2]), "Truck", 0.95); } else if (input[1] == "Bus") { vehicles.Find(x => x.GetType().Name == "Bus").VehicleRefueling( double.Parse(input[2]), "Bus", 1); } break; } } catch (ArgumentException a) { Console.WriteLine(a.Message); } } foreach (var item in vehicles) { Console.WriteLine(item.GetType().Name + $": {item.FuelQuantity:f2}"); } }
public string Execute(ICommand command) { if (command.Name != "SetupPark" && this.vehiclePark == null) { return Message.VehicleParkNotSetUp; } var message = string.Empty; switch (command.Name) { case "SetupPark": this.vehiclePark = new VehiclePark( int.Parse(command.Parameters["sectors"]), int.Parse(command.Parameters["placesPerSector"])); message = Message.VehicleParkCreated; break; case "Park": var licensePlate = command.Parameters["licensePlate"]; var owner = command.Parameters["owner"]; var reservedHours = int.Parse(command.Parameters["hours"]); var place = int.Parse(command.Parameters["place"]); var sector = int.Parse(command.Parameters["sector"]); var time = DateTime.Parse(command.Parameters["time"]); switch (command.Parameters["type"]) { case "car": var car = new Car(licensePlate, owner, reservedHours); message = this.vehiclePark.InsertCar(car, sector, place, time); break; case "motorbike": var bike = new Motorbike(licensePlate, owner, reservedHours); message = this.vehiclePark.InsertMotorbike(bike, sector, place, time); break; case "truck": var truck = new Truck(licensePlate, owner, reservedHours); message = this.vehiclePark.InsertTruck(truck, sector, place, time); break; } break; case "Exit": var exitLicesencePlate = command.Parameters["licensePlate"]; var exitTime = DateTime.Parse(command.Parameters["time"]); var moneyOwed = decimal.Parse(command.Parameters["paid"]); message = this.vehiclePark.ExitVehicle( exitLicesencePlate, exitTime, moneyOwed); break; case "Status": message = this.vehiclePark.GetStatus(); break; case "FindVehicle": message = this.vehiclePark.FindVehicle(command.Parameters["licensePlate"]); break; case "VehiclesByOwner": message = this.vehiclePark.FindVehiclesByOwner(command.Parameters["owner"]); break; default: throw new InvalidOperationException("Invalid command"); } return message; }
public void Run() { // Car {fuel quantity} {liters per km} // Truck {fuel quantity} {liters per km} string[] carInfo = Console.ReadLine().Split(); string[] truckInfo = Console.ReadLine().Split(); string[] busInfo = Console.ReadLine().Split(); double carFuelQuantity = double.Parse(carInfo[1]); double carConsumption = double.Parse(carInfo[2]); double carCapacity = double.Parse(carInfo[3]); double truckFuelQuantity = double.Parse(truckInfo[1]); double truckConsumption = double.Parse(truckInfo[2]); double truckCapacity = double.Parse(truckInfo[3]); double busFuelQuantity = double.Parse(busInfo[1]); double busConsumption = double.Parse(busInfo[2]); double busCapacity = double.Parse(busInfo[3]); IVehicles car = new Car(carFuelQuantity, carConsumption, carCapacity); IVehicles truck = new Truck(truckFuelQuantity, truckConsumption, truckCapacity); IVehicles bus = new Bus(busFuelQuantity, busConsumption, busCapacity); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { //• "Drive Car {distance}" //• "Drive Truck {distance}" //• "Refuel Car {liters}" //• "Refuel Truck {liters}" string[] inputArgs = Console.ReadLine().Split(); string action = inputArgs[0]; string vehicleType = inputArgs[1]; double value = double.Parse(inputArgs[2]); try { if (action == "Drive") { if (vehicleType == "Car") { car.Drive(value); } else if (vehicleType == "Truck") { truck.Drive(value); } else if (vehicleType == "Bus") { bus.IsVehicleEmpty = false; bus.Drive(value); } } else if (action == "DriveEmpty") { bus.IsVehicleEmpty = true; bus.Drive(value); } else if (action == "Refuel") { if (vehicleType == "Car") { car.Refuel(value); } else if (vehicleType == "Truck") { truck.Refuel(value); } else if (vehicleType == "Bus") { bus.Refuel(value); } } } catch (ArgumentException ae) { Console.WriteLine(ae.Message);; } } Console.WriteLine(car); Console.WriteLine(truck); Console.WriteLine(bus); }
public bool Delete(Truck entity) { return _truckRepo.Delete(entity); }
private void btSave_Click(object sender, EventArgs e) { try { Int32.Parse(registration.Text); Int32.Parse(Kilometer.Text); Int32.Parse(costperdatetext.Text); if (CheckedNotNull()) { if (change) { UpdateVehicle(); MessageBox.Show("Update successly!"); change = false; manage = Program.LoadData(); } else { if (CheckId(Int32.Parse(registration.Text))) { Vehicle vehicle; if ((RadioCarDetail.Checked)) { if (descriptiontext.Text == "") { vehicle = new Car(NameVehicle.Text, BranchVehicle.Text, Int32.Parse(registration.Text), (TypeCar)Enum.Parse(typeof(TypeCar), typeVehicledetail.SelectedItem.ToString()), maintainvehicleview.Checked, statusvehicleview.Checked, Int32.Parse(costperdatetext.Text), Int32.Parse(Kilometer.Text)); } else { vehicle = new Car(NameVehicle.Text, BranchVehicle.Text, Int32.Parse(registration.Text), (TypeCar)Enum.Parse(typeof(TypeCar), typeVehicledetail.SelectedItem.ToString()), maintainvehicleview.Checked, statusvehicleview.Checked, Int32.Parse(costperdatetext.Text), Int32.Parse(Kilometer.Text), descriptiontext.Text); } } else { if (descriptiontext.Text == "") { vehicle = new Truck(NameVehicle.Text, BranchVehicle.Text, Int32.Parse(registration.Text), (TypeTruck)Enum.Parse(typeof(TypeTruck), typeVehicledetail.SelectedItem.ToString()), maintainvehicleview.Checked, statusvehicleview.Checked, Int32.Parse(costperdatetext.Text), Int32.Parse(Kilometer.Text)); } else { vehicle = new Truck(NameVehicle.Text, BranchVehicle.Text, Int32.Parse(registration.Text), (TypeTruck)Enum.Parse(typeof(TypeTruck), typeVehicledetail.SelectedItem.ToString()), maintainvehicleview.Checked, statusvehicleview.Checked, Int32.Parse(costperdatetext.Text), Int32.Parse(Kilometer.Text), descriptiontext.Text); } } InsertVehicle(vehicle); MessageBox.Show("Add Successly!"); addnew = false; manage = Program.LoadData(); } } setclear(); SetUnChange(); if (RadioCarview.Checked) { LoadCar(); } else { loadTruck(); } } } catch (Exception error) { MessageBox.Show("Please fill correct!"); } }
private static void Main() { Bicycle bicycle = new Bicycle("Chicago Bicycle", 2011, "K-10", 100); bicycle.Color = "Red"; bicycle.GetDetails(); bicycle.Accelerate(50); bicycle.Deaccelerate(10); if (bicycle.IsMoving()) { Console.WriteLine("Bicycle is moving"); } else { Console.WriteLine("Bicycle is not moving"); } Console.WriteLine(""); Bike bike = new Bike("Hero Bike", 2015, "H712", 200); bike.BikeColor = "Blue"; bike.GetDetails(); bike.Accelerate(30); bike.Deaccelerate(40); bike.Stop(); if (bike.IsMoving()) { Console.WriteLine("Bike is moving"); } else { Console.WriteLine("Bike is not moving"); } Console.WriteLine(""); Car car = new Car("Honda Amaze", 2016, "VXi", 250); car.CarColor = "White"; car.GetDetails(); car.Accelerate(10); car.Deaccelerate(270); if (car.IsMoving()) { Console.WriteLine("Car is moving"); } else { Console.WriteLine("Car is not moving"); } Console.WriteLine(""); Truck truck = new Truck("Aven", 2010, "Z-20", 200); truck.TruckColor = "Orange"; truck.GetDetails(); truck.Accelerate(10); truck.Deaccelerate(20); if (truck.IsMoving()) { Console.WriteLine("Truck is moving"); } else { Console.WriteLine("Truck is not moving"); } Console.ReadKey(); }
/// <summary> /// Calculates the real maximal truck weight /// </summary> /// <param name="t"> /// Truck | the truck object /// </param> /// <returns> /// int | real max weight /// </returns> private int GetTruckMaxWeight(Truck t) => t.MaxWeight - ((t.DriverWeight[0] + t.DriverWeight[1]) / 2);
public void Run() { string[] carInfo = Console.ReadLine().Split(); string[] truckInfo = Console.ReadLine().Split(); string[] busInfo = Console.ReadLine().Split(); double carFuelQuantity = double.Parse(carInfo[1]); double carFuelConsumption = double.Parse(carInfo[2]); double carTankCapacity = double.Parse(carInfo[3]); double truckFuelQuantity = double.Parse(truckInfo[1]); double truckFuelConsumption = double.Parse(truckInfo[2]); double truckTankCapacity = double.Parse(truckInfo[3]); double busFuelQuantity = double.Parse(busInfo[1]); double busFuelConsumption = double.Parse(busInfo[2]); double busTankCapacity = double.Parse(busInfo[3]); IVehicle car = new Car(carFuelQuantity, carFuelConsumption, carTankCapacity); IVehicle truck = new Truck(truckFuelQuantity, truckFuelConsumption, truckTankCapacity); IVehicle bus = new Bus(busFuelQuantity, busFuelConsumption, busTankCapacity); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { try { string[] inputArgs = Console.ReadLine().Split(); string action = inputArgs[0]; string vehicleType = inputArgs[1]; double value = double.Parse(inputArgs[2]); if (action == "Refuel") { if (vehicleType == "Car") { car.Refuel(value); } else if (vehicleType == "Truck") { truck.Refuel(value); } else if (vehicleType == "Bus") { bus.Refuel(value); } } else if (action == "Drive") { if (vehicleType == "Car") { car.Drive(value); } else if (vehicleType == "Truck") { truck.Drive(value); } else if (vehicleType == "Bus") { bus.IsVehicleEmpty = false; bus.Drive(value); } } else if (action == "DriveEmpty") { bus.IsVehicleEmpty = true; bus.Drive(value); } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } } Console.WriteLine(car); Console.WriteLine(truck); Console.WriteLine(bus); }
void OnTriggerEnter(Collider other) { PlayerController playerHit; if (player == PlayerWhoOwnsTheBullet.Player1) { if (other.tag == "Player2" || other.tag == "Player3" || other.tag == "Player4") { playerHit = other.GetComponent <PlayerController> (); if (!playerHit.invulnerable) { playerHit.TakeDamage(); } if (direction == 1) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 90))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 2) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 3) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 270))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 4) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 5) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 6) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 7) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } Destroy(gameObject); } } else if (player == PlayerWhoOwnsTheBullet.Player2) { if (other.tag == "Player1" || other.tag == "Player3" || other.tag == "Player4") { playerHit = other.GetComponent <PlayerController> (); if (!playerHit.invulnerable) { playerHit.TakeDamage(); } if (direction == 1) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 90))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 2) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 3) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 270))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 4) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 5) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 6) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 7) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } Destroy(gameObject); } } else if (player == PlayerWhoOwnsTheBullet.Player3) { if (other.tag == "Player1" || other.tag == "Player2" || other.tag == "Player4") { playerHit = other.GetComponent <PlayerController> (); if (!playerHit.invulnerable) { playerHit.TakeDamage(); } if (direction == 1) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 90))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 2) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 3) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 270))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 4) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 5) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 6) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 7) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } Destroy(gameObject); } } else { if (other.tag == "Player1" || other.tag == "Player2" || other.tag == "Player3") { playerHit = other.GetComponent <PlayerController> (); if (!playerHit.invulnerable) { playerHit.TakeDamage(); } if (direction == 1) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 90))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 2) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 3) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 270))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 4) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 5) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 6) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 7) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } Destroy(gameObject); } } if (other.tag == "PaintableFloor") { PaintableFloor floor = other.GetComponent <PaintableFloor> (); if (selectedColor == SelectedColor.Blue) { floor.PaintBlue(); } else if (selectedColor == SelectedColor.Green) { floor.PaintGreen(); } else if (selectedColor == SelectedColor.Red) { floor.PaintRed(); } else { floor.PaintYellow(); } GameObject effect = (GameObject)Instantiate(shotHitPrefab, transform.position, Quaternion.Euler(new Vector3(0, 45, 270))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; Destroy(gameObject); } if (other.tag == "Truck") { Truck truck = other.GetComponent <Truck> (); if (selectedColor == SelectedColor.Blue) { truck.PaintBlue(); } else if (selectedColor == SelectedColor.Green) { truck.PaintGreen(); } else if (selectedColor == SelectedColor.Red) { truck.PaintRed(); } else { truck.PaintYellow(); } if (direction == 1) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 90))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 2) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 3) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 270))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 4) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 5) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 6) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else if (direction == 7) { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 180))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } else { GameObject effect = (GameObject)Instantiate(shotHitPrefab, other.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; } Destroy(gameObject); } if (other.tag == "Ground") { GameObject effect = (GameObject)Instantiate(shotHitPrefab, transform.position, Quaternion.Euler(new Vector3(0, 45, 270))); effect.GetComponent <ShotHit> ().selectedColor = selectedColor; Destroy(gameObject); } }
static void Main(string[] args) { List <Car> cars = new List <Car>(); List <Truck> trucks = new List <Truck>(); string[] data = new string[4]; while (true) { data = Console.ReadLine() .Split() .ToArray(); if (data[0] == "End") { break; } string type = data[0]; string model = data[1]; string color = data[2]; int horsePower = int.Parse(data[3]); if (data[0].ToLower() == "car") { Car car = new Car(); { car.Type = type; car.Model = model; car.Color = color; car.HorsePower = horsePower; } cars.Add(car); } else if (data[0].ToLower() == "truck") { Truck truck = new Truck() { Type = type, Model = model, Color = color, HorsePower = horsePower }; trucks.Add(truck); } } while (true) { string newModels = Console.ReadLine(); if (newModels == "Close the Catalogue") { break; } for (int i = 0; i < cars.Count; i++) { if (cars[i].Model.Contains(newModels)) { Console.WriteLine($"Type: Car"); Console.WriteLine($"Model: {cars[i].Model}"); Console.WriteLine($"Color: {cars[i].Color}"); Console.WriteLine($"Horsepower: {cars[i].HorsePower}"); } } for (int i = 0; i < trucks.Count; i++) { if (trucks[i].Model.Contains(newModels)) { Console.WriteLine($"Type: Truck"); Console.WriteLine($"Model: {trucks[i].Model}"); Console.WriteLine($"Color: {trucks[i].Color}"); Console.WriteLine($"Horsepower: {trucks[i].HorsePower}"); } } } int carsCount = 0; int trucksCount = 0; double carsHorsePower = 0.0; double trucksHorsePower = 0.0; for (int i = 0; i < cars.Count; i++) { if (cars[i].Type == "car") { carsCount++; carsHorsePower += cars[i].HorsePower; } } for (int i = 0; i < trucks.Count; i++) { if (trucks[i].Type == "truck") { trucksCount++; trucksHorsePower += trucks[i].HorsePower; } } if (cars.Count > 0) { Console.WriteLine($"Cars have average horsepower of: {((double)cars.Sum(x => x.HorsePower) / cars.Count):f2}."); } else { Console.WriteLine($"Cars have average horsepower of: {0:F2}."); } if (trucks.Count > 0) { Console.WriteLine($"Trucks have average horsepower of: {((double)trucks.Sum(x => x.HorsePower) / trucks.Count):f2}."); } else { Console.WriteLine($"Trucks have average horsepower of: {0:F2}."); } }
public void Prepare() { ISession s = tc.OpenNewSession(); ITransaction txn = s.BeginTransaction(); Polliwog = new Animal { BodyWeight = 12, Description = "Polliwog" }; Catepillar = new Animal { BodyWeight = 10, Description = "Catepillar" }; Frog = new Animal { BodyWeight = 34, Description = "Frog" }; Polliwog.Father = Frog; Frog.AddOffspring(Polliwog); Butterfly = new Animal { BodyWeight = 9, Description = "Butterfly" }; Catepillar.Mother = Butterfly; Butterfly.AddOffspring(Catepillar); s.Save(Frog); s.Save(Polliwog); s.Save(Butterfly); s.Save(Catepillar); var dog = new Dog { BodyWeight = 200, Description = "dog" }; s.Save(dog); var cat = new Cat { BodyWeight = 100, Description = "cat" }; s.Save(cat); Zoo = new Zoo { Name = "Zoo" }; var add = new Address { City = "MEL", Country = "AU", Street = "Main st", PostalCode = "3000" }; Zoo.Address = add; PettingZoo = new PettingZoo { Name = "Petting Zoo" }; var addr = new Address { City = "Sydney", Country = "AU", Street = "High st", PostalCode = "2000" }; PettingZoo.Address = addr; s.Save(Zoo); s.Save(PettingZoo); var joiner = new Joiner { JoinedName = "joined-name", Name = "name" }; s.Save(joiner); var car = new Car { Vin = "123c", Owner = "Kirsten" }; s.Save(car); var truck = new Truck { Vin = "123t", Owner = "Steve" }; s.Save(truck); var suv = new SUV { Vin = "123s", Owner = "Joe" }; s.Save(suv); var pickup = new Pickup { Vin = "123p", Owner = "Cecelia" }; s.Save(pickup); var b = new BooleanLiteralEntity(); s.Save(b); txn.Commit(); s.Close(); }
public void setCarrier(Truck t) { carrier = t; }
public static double CalculateContainerVolumeUtilization(Truck truck) { return(truck.Items.Aggregate(0.0, (current, item) => current + item.Volume) / truck.Volume); }
public Vehicle(Truck truck) { Trucks = truck; }
public void Run() { Car car = carFactory.MakeCar(); Truck truck = truckFactory.MakeTruck(); Bus bus = busFactory.MakeBus(); int commandCount = int.Parse(Console.ReadLine()); for (int i = 0; i < commandCount; i++) { string[] commandData = Console.ReadLine().Split(); string commandType = commandData[0]; string vehicleType = commandData[1]; if (commandType.ToLower() == "drive") { double distance = double.Parse(commandData[2]);; if (vehicleType.ToLower() == "car") { Console.WriteLine(car.Drive(distance)); } else if (vehicleType.ToLower() == "truck") { Console.WriteLine(truck.Drive(distance)); } else if (vehicleType.ToLower() == "bus") { Console.WriteLine(bus.Drive(distance)); } } else if (commandType.ToLower() == "refuel") { double fuel = double.Parse(commandData[2]);; try { if (vehicleType.ToLower() == "car") { car.Refuel(fuel); } else if (vehicleType.ToLower() == "truck") { truck.Refuel(fuel); } else if (vehicleType.ToLower() == "bus") { bus.Refuel(fuel); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { double distance = double.Parse(commandData[2]);; Console.WriteLine(bus.DriveEmpty(distance)); } } Console.WriteLine(car); Console.WriteLine(truck); Console.WriteLine(bus); }
public string InsertTruck(Truck truck, int sector, int placeNumber, DateTime startTime) { return this.InsertVehicle(truck, sector, placeNumber, startTime); }
public void Run() { //Car 15 0.3 //Truck 100 0.9 string[] carArgs = Console.ReadLine().Split(); string[] truckArgs = Console.ReadLine().Split(); string[] busArgs = Console.ReadLine().Split(); // var fuelCarQuantity = double.Parse(carArgs[1]); var fuelCarConsumation = double.Parse(carArgs[2]); var fuelCarTank = double.Parse(carArgs[3]); var fuelTruckQuantity = double.Parse(truckArgs[1]); var fuelTruckConsumation = double.Parse(truckArgs[2]); var fuelTruckTank = double.Parse(truckArgs[3]); var fuelBusQuantity = double.Parse(busArgs[1]); var fuelBusConsumation = double.Parse(busArgs[2]); var fuelBusTank = double.Parse(busArgs[3]); // IVehicles car = new Car(fuelCarConsumation, fuelCarQuantity, fuelCarTank); IVehicles truck = new Truck(fuelTruckConsumation, fuelTruckQuantity, fuelTruckTank); IVehicles bus = new Bus(fuelBusConsumation, fuelBusQuantity, fuelBusTank); // int count = int.Parse(Console.ReadLine()); for (int i = 0; i < count; i++) { //Drive Car 9 try { string[] inptArgs = Console.ReadLine().Split(); string command = inptArgs[0]; string type = inptArgs[1]; double parameter = double.Parse(inptArgs[2]); // if (command == "Drive") { if (type == "Car") { car.Driven(parameter); } else if (type == "Truck") { truck.Driven(parameter); } else if (type == "Bus") { bus.Driven(parameter); } } else if (command == "Refuel") { if (type == "Car") { car.Refueled(parameter); } else if (type == "Truck") { truck.Refueled(parameter); } else if (type == "Bus") { bus.IsVehicleEmty = false; bus.Refueled(parameter); } } else if (command == "DriveEmpty") { bus.IsVehicleEmty = true; bus.Driven(parameter); } } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } } Console.WriteLine(car); Console.WriteLine(truck); Console.WriteLine(bus); }