public Vehicle(int id, VehicleType type, AbstractEngine engine, string modelName, string regNumber, int weight, int manufactureYear, int mileage, Colour colour, int tankCapacity, List <Rent> RentList) { this.id = id; this.type = type; this.engine = engine; this.modelName = modelName; this.regNumber = regNumber; this.weight = weight; this.manufactureYear = manufactureYear; this.mileage = mileage; this.colour = colour; this.tankCapacity = tankCapacity; this.RentList = RentList; }
internal Vehicle CreateVehicle(string csvString) { var vehTypes = LoadTypes("types.csv"); string[] fields = csvString.Split(';'); int id = int.Parse(fields[0]); VehicleType vehType = null; foreach (var type in vehTypes) { if (int.Parse(fields[1]) == type.IdType) { vehType = type; break; } } string modelName = fields[2]; string modelNumber = fields[3]; int carWeight = int.Parse(fields[4]); int manufactureYear = int.Parse(fields[5]); int carMileage = int.Parse(fields[6]); Color carColor = (Color)Enum.Parse(typeof(Color), fields[7]); double carTankCapacity = double.Parse(fields[11]); AbstractEngine engine = null; switch (fields[8]) { case "Gasoline": engine = new GasolineEngine(double.Parse(fields[9]), double.Parse(fields[10])); break; case "Diesel": engine = new DieselEngine(double.Parse(fields[9]), double.Parse(fields[10])); break; case "Electrical": engine = new ElectricalEngine(double.Parse(fields[10])); break; } return(new Vehicle(id, vehType, engine, modelName, modelNumber, carWeight, manufactureYear, carMileage, carColor, carTankCapacity)); }
public Vehicle(int id, VehicleType type, AbstractEngine carEngine, string modelName, string registrationNumber, int weight, int manufactureYear, int mileage, Color carColor, double tankCapacity) { Id = id; Type = type; CarEngine = carEngine; ModelName = modelName; RegistrationNumber = registrationNumber; Weight = weight; ManufactureYear = manufactureYear; Mileage = mileage; CarColor = carColor; TankCapacity = tankCapacity; }
public Vehicle CreateVehicle(string csvString) { string[] s = csvString.Split(","); List <VehicleType> localTypes = LoadTypes(@"types.csv"); AbstractEngine localEngine = null; Vehicle.Colour localColour = (Vehicle.Colour)Enum.Parse(typeof(Vehicle.Colour), s[7]); if (s[8] == "Electrical") { localEngine = new ElectricalEngine(int.Parse(s[9])); } else if (s[8] == "Gasoline") { localEngine = new GasolineEngine(double.Parse(s[10], System.Globalization.CultureInfo.InvariantCulture), double.Parse(s[9], System.Globalization.CultureInfo.InvariantCulture)); } else if (s[8] == "Diesel") { localEngine = new DieselEngine(double.Parse(s[10], System.Globalization.CultureInfo.InvariantCulture), double.Parse(s[9], System.Globalization.CultureInfo.InvariantCulture)); } return(new Vehicle(int.Parse(s[0]), localTypes[int.Parse(s[1]) - 1], localEngine, s[2], s[3], int.Parse(s[4]), int.Parse(s[5]), int.Parse(s[6]), localColour, int.Parse(s[11]), new List <Rent>())); }
private static AbstractEngine GetEngineByString(string engineString) { AbstractEngine engine = null; string[] engineStringPieces = engineString.Split(' ', StringSplitOptions.RemoveEmptyEntries); var engineType = Enum.Parse <EngineTypes>(engineStringPieces[0]); switch (engineType) { case EngineTypes.Gasoline: engine = new GasolineEngine ( double.Parse(engineStringPieces[1]), double.Parse(engineStringPieces[2]) ); break; case EngineTypes.Diesel: engine = new DieselEngine ( double.Parse(engineStringPieces[1]), double.Parse(engineStringPieces[2]) ); break; case EngineTypes.Electrical: engine = new ElectricalEngine ( double.Parse(engineStringPieces[1]) ); break; default: break; } return(engine); }
public Vehicle( int id, VehicleType type, AbstractEngine engineType, string modelName, string registrationNumber, double weight, int manufactureYear, double mileage, double tankVolume, Color color) { Id = id; Type = type; EngineType = engineType; ModelName = modelName; RegistrationNumber = registrationNumber; Weight = weight; ManufactureYear = manufactureYear; Mileage = mileage; TankVolume = tankVolume; Color = color; Rents = new List <Rent>(); }
public double GetCalcTaxPerMonth(int weight, VehicleType type, AbstractEngine carEngine) { return((weight * 0.0013) + (type.RoadTaxRate * carEngine.EngineTaxRate * 30) + 5); }