public List <string> GetAttributesList() { List <string> attributes = new List <string>(); attributes.Add(rego); attributes.Add(Make); attributes.Add(Model); attributes.Add(Year.ToString()); attributes.Add(VehClass); attributes.Add(Seats.ToString()); attributes.Add(Transmission); attributes.Add(Fuel); if (gps == true) { attributes.Add("gps"); } attributes.Add(SunRoof.ToString()); if (SunRoof == true) { attributes.Add("sunroof"); } attributes.Add(DailyRate.ToString()); attributes.Add(Colour); return(attributes); }
static void Main(string[] args) { Car theCar = new CompactCar(); theCar = new LeatherSeats(theCar); theCar = new Navigation(theCar); theCar = new SunRoof(theCar); Console.WriteLine(theCar.GetCarDescription()); Console.WriteLine($"{theCar.GetCarPrice():C2}"); Console.ReadKey(); }
public void Should_Pass_If_Can_Calculate_Compact_Car_Price_With_Navigation_And_SunRoof_Correctly() { // arrange CompactCar car = new CompactCar(); Navigation navigation = new Navigation(car); SunRoof sunRoof = new SunRoof(navigation); // act var price = sunRoof.GetPrice(); // assert Assert.Equal(103_300_000, price); }
} // end of previous method - ToString() // --------------------------------------------------------------------- /// <summary> /// This method should return a list of strings which represent each attribute. Values /// should be made to be unique, e.g.numSeats should not be written as ‘4’ but as ‘4- /// Seater’, sunroof should not be written as ‘True’ but as ‘sunroof’ or with no string /// added if there is no sunroof.Vehicle rego, class, make, model, year, transmission /// type, fuel type, daily rate, and colour can all be assumed to not overlap(i.e. if /// the make ‘Mazda’ exists, ‘Mazda’ will not exist in other attributes e.g.there is /// no model named ‘Mazda’. Similarly, if the colour ‘red’ exists, there is no ‘red’ /// make.You do not need to maintain this restriction, only assume it is true.) /// </summary> public List <string> GetAttributeList() { List <string> attributes = new List <string>(); attributes.Add(VehicleRego); attributes.Add(Make); attributes.Add(Model); attributes.Add(Year.ToString()); attributes.Add(VehicleClass.ToString()); attributes.Add(NumSeats + "-Seater"); attributes.Add(TransmissionType.ToString()); attributes.Add(EngineSize + "-Cylinder"); attributes.Add(Turbo.ToString()); attributes.Add(FuelType.ToString()); attributes.Add(GPS.ToString()); attributes.Add(SunRoof.ToString()); attributes.Add(Colour); attributes.Add(DailyRate.ToString()); return(attributes); } // end of previous method - GetAttributeList()
public string ToCSVString() { string csvString = ""; csvString = csvString + Registration + "," + Grade + "," + Make + "," + Model + "," + Year.ToString() + "," + NumSeats.ToString() + "," + Transmission + "," + Fuel + "," + GPS.ToString() + "," + SunRoof.ToString() + "," + DailyRate.ToString() + "," + Colour + ""; return(csvString); }