Page 1 of 1

Your answer: 27 Define a method listCarsByMake(), to be added to the GarageList class, which would return the registrati

Posted: Sat May 14, 2022 3:00 pm
by answerhappygod
Your Answer 27 Define A Method Listcarsbymake To Be Added To The Garagelist Class Which Would Return The Registrati 1
Your Answer 27 Define A Method Listcarsbymake To Be Added To The Garagelist Class Which Would Return The Registrati 1 (30.07 KiB) Viewed 67 times
Your Answer 27 Define A Method Listcarsbymake To Be Added To The Garagelist Class Which Would Return The Registrati 2
Your Answer 27 Define A Method Listcarsbymake To Be Added To The Garagelist Class Which Would Return The Registrati 2 (87.96 KiB) Viewed 67 times
Your Answer 27 Define A Method Listcarsbymake To Be Added To The Garagelist Class Which Would Return The Registrati 3
Your Answer 27 Define A Method Listcarsbymake To Be Added To The Garagelist Class Which Would Return The Registrati 3 (49.09 KiB) Viewed 67 times
case study given answer the question
assume and solve it please
Your answer: 27 Define a method listCarsByMake(), to be added to the GarageList class, which would return the registrations of all Car object (as a String) whose make is given by a parameter value. ma Your answer:

SECTION B Case Study A This section relates to the Java programming language. TestRunner ListRunner CarTest Garagelist Car } Date public class Car { private String regno; private String make; private Date registered; private int milage; private double cost; private double costPaid; 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

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); 1 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 }