Mock Pra 1 Answer
Mock Pra 1 Answer
Mock Pra 1 Answer
}
String regNo=sc.nextLine();
Car temp=getCar(c,regNo);
int count=getACCarCount(c);
if(temp!=null) {
System.out.println(temp.getPrice());
}
else {
System.out.println("Car RegNo not found");
}
System.out.println(count);
}
public static Car getCar(Car[] carList, String carRegNo)
{
//method logic
Car t=null;
for(int i=0;i<4;i++) {
if(carList[i].getRegNo().equalsIgnoreCase(carRegNo)) {
t=carList[i];
}
}
return t;
}
public static int getACCarCount(Car[] carList)
{
int count=0;
for(int i=0;i<4;i++) {
if(carList[i].isACCar()) {
count++;
}
}
return count;
}
}
class Car
{
private String regNo;
private double price;
private boolean isACCar;
private String company;
public String getRegNo() {
return regNo;
}
public void setRegNo(String regNo) {
this.regNo = regNo;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public boolean isACCar() {
return isACCar;
}
public void setACCar(boolean isACCar) {
this.isACCar = isACCar;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public Car(String regNo, double price, boolean isACCar, String company) {
super();
this.regNo = regNo;
this.price = price;
this.isACCar = isACCar;
this.company = company;
}