Page 1 of 1

26 ma Write the code to be included in the CarTest class, which: i. declares a Car object called myCar and creates it wi

Posted: Sat May 14, 2022 3:00 pm
by answerhappygod
26 Ma Write The Code To Be Included In The Cartest Class Which I Declares A Car Object Called Mycar And Creates It Wi 1
26 Ma Write The Code To Be Included In The Cartest Class Which I Declares A Car Object Called Mycar And Creates It Wi 1 (38.44 KiB) Viewed 37 times
26 Ma Write The Code To Be Included In The Cartest Class Which I Declares A Car Object Called Mycar And Creates It Wi 2
26 Ma Write The Code To Be Included In The Cartest Class Which I Declares A Car Object Called Mycar And Creates It Wi 2 (85.86 KiB) Viewed 37 times
26 Ma Write The Code To Be Included In The Cartest Class Which I Declares A Car Object Called Mycar And Creates It Wi 3
26 Ma Write The Code To Be Included In The Cartest Class Which I Declares A Car Object Called Mycar And Creates It Wi 3 (53.7 KiB) Viewed 37 times
case study given answer the question
26 ma Write the code to be included in the CarTest class, which: i. declares a Car object called myCar and creates it with the Car registration : LV07GBG. a Nissan, with a milage of 30,000 miles i. then outputs to the terminal window the make of a Car zCar (which has already been declared and created in previous code) Your answer:

SECTION B Case Study A This section relates to the Java programming language. TestRunner LisiRunner CarTest Garage List Car Date public class Car { private String regNo; private String make; private Date registered; private int milage; private double cost; private double cost Paid; public Car (String reg, String mk, int mls) { make = mk; regNo = reg; milage = 0; cost = 0; cost Paid = 0; registered = null; } public String getRegistration() { return regno; } public void setCost (double f) { cost = f; //remaining code omitted but could include: Car(), updateMilage (). toString(), getMake () and other accessors/mutators/constructors ) // continued below

1 public class GarageList private String name; private int areaCode; private ArrayList<Car> carList = new ArrayList<Car>(); public GarageList(String nme, int cd) name = nme; areaCode - cd; public void addCar (Car s) carlist.add(s); } public Car findCar (String cNo) { for (int index = 0; index < carlist.size(); index++) { Car temp = carlist.get (index); tempreg = temp.getRegistration (); if (cNo.equals (tempReg)) { return temp; } } return null; } //remaining code omitted