Car.java - PART 1 import java.util.Scanner public class Car private private private private private private String make String model int price int year
Car.java - PART 1 import java.util.Scanner public class Car...
// PART 1import java.util.Scanner;public class Car {private String make; private String model;private int price;private int year;private static int carNum=0;private static int menu;// default constructorpublic Car() {this.make=null;this.model=null;this.price=0;this.year=0; }// parametrized constructorpublic Car(String make, String model, int price, int year){this.make=make;this.model=model;this.price=price;this.year=year;}// copy constructorpublic Car(Car aCar){this.make=aCar.make;this.model=aCar.model;this.price=aCar.price;this.year=aCar.year;}// accessor methodspublic String getMake() {return make;}public String getModel() {return model;}public int getPrice() {return price;}public int getYear() {return year;}// mutator methodspublic void setMake(String Make) {this.make = make;}public void setModel(String Model) {this.model = model;}public void setPrice(int Price) {
this.price = price;}public void setYear(int Price) {this.year = year;}/*** Returns the total number of cars that have been created.* @return an int representing the total number of created cars.*/public static int findNumberOfCreatedCars() {return carNum;}/*** Compares the values of the price of the car to determine if two cars have the same price.* @param other The other Car that is being compared.* @return true if both prices are the same, and false if both are not the same.*/public boolean equals(Car otherCar){return((price==otherCar.price) && (year==otherCar.year));}// display car object infopublic String toString() {return ("Make: "+make+"\n"+"Model: "+model+"\n"+"Price: $"+price+"\n"+"Year: "+year+"\n");}/*** Searches all the created car objects in database and prints the ones by the desired make and model.* @param make The make the user wishes to search for.* @param model The model the user wishes to search for.*/public static void findCarBy(Car[] carDatabase, String make, String model) {int carsFound = 0;for (int i =0; i<carDatabase.length; i++) {if (carDatabase[i] != null && carDatabase[i].getMake().equals(make) &&carDatabase[i].getModel().equals(model)) {System.out.println(carDatabase[i]);System.out.println("");