public Engine(string name, int hp, float volume, TypeOfFuel fuelType) { Name = name; HP = hp; Volume = volume; FuelType = fuelType; }
/// <summary> /// Create a car without a owner /// </summary> /// <param name="licenseplate"></param> /// <param name="fueltype"></param> /// <param name="brand"></param> /// <param name="fuelcapacity"></param> public Car(string licenseplate, TypeOfFuel fueltype, string brand, double fuelcapacity) { Licenseplate = licenseplate; Fueltype = fueltype; Brand = brand; FuelCapacity = fuelcapacity; Owner = null; }
public override string ToString() { string DataOfMotorcycelWorkingOnGas; DataOfMotorcycelWorkingOnGas = string.Format("Type Of Fuel: {0}{3}" + "Amount Of Fuel Present In Liters: {1}{3}" + "Maximum Amount Of Fuel In Liters: {2}{3}" , TypeOfFuel.ToString(), (this as Vehicles).VehicleEnergy.RemainingEnergy.ToString().ToString(), MaximumAmountOfFuelInLiters.ToString(), Environment.NewLine); return(DataOfMotorcycelWorkingOnGas + base.ToString()); }
public async Task <HttpResponseMessage> Put(TypeOfFuel typeOfFuel) { try { var client = _carFactory.CreateClient("Cars"); var response = await client.PutAsJsonAsync <TypeOfFuel>("TypeOfFuel", typeOfFuel); return(response); } catch (Exception) { throw; } }
public void Refuel(TypeOfFuel fuel, double amount) { if (fuel != Fuel) { throw new Exception("Not same type of fuel"); } if (amount + StateOfTank > SizeOfTank) { throw new Exception("Tank was over floaded"); } else { StateOfTank = StateOfTank + amount; } }
public async Task <int> Update(TypeOfFuel entity) { var sql = "UPDATE TypeOfFuels SET Description = @Description, Status = @Status WHERE ID = @ID;"; try { using (var connection = new SqlConnection(_configuration.GetConnectionString("CarConnection"))) { connection.Open(); var affectedRows = await connection.ExecuteAsync(sql, entity); return(affectedRows); } } catch (Exception) { throw; } }
public async Task <int> Add(TypeOfFuel entity) { var sql = "INSERT INTO TypeOfFuels (Description, Status) " + "Values (@Description, @Status);"; try { using (var connection = new SqlConnection(_configuration.GetConnectionString("CarConnection"))) { connection.Open(); var affectedRows = await connection.ExecuteAsync(sql, entity); return(affectedRows); } } catch (Exception) { throw; } }
public async Task <IActionResult> Post(TypeOfFuel typeOfFuel) { try { var response = await _repository.Add(typeOfFuel); if (response != 0) { return(Ok("Added successfully")); } else { return(BadRequest("An error ocurred, contact IT Staff")); } } catch (Exception e) { //Log error Log.Error(e.Message); Log.Error(e.StackTrace); return(BadRequest("An error ocurred, contact IT Staff")); } }
public PassengerCar(double sizeOfTank, TypeOfFuel fuel, int maxPersons, double stateOfTank = 0, int transportedPersons = 0) : base(sizeOfTank, fuel, stateOfTank) { MaxPersons = maxPersons; TransportedPersons = transportedPersons; }
public Car(double sizeOfTank, TypeOfFuel fuel, double stateOfTank = 0) { SizeOfTank = sizeOfTank; StateOfTank = stateOfTank; Fuel = fuel; }
public Lorry(double sizeOfTank, TypeOfFuel fuel, double maxLoad, double stateOfTank = 0, double transportedLoad = 0) : base(sizeOfTank, fuel, stateOfTank) { MaxLoad = maxLoad; TransportedLoad = transportedLoad; }