Suppose you are working for a used car lot that needs to keep inventory of its cars. One car is a 2011 Chevrolet Cruze of vehicle ID “1G1JF27W8GJ178227” , i.e make Chevrolet, model Cruze, year 2011, vehicle ID (or VIN) “1G1JF27W8GJ178227” You have been asked to implement an Automobile class with API as follows:
public class Automobile
Automobile(String make,
String model, int year, String vehicleID)
String getMake() car’s make
String getModel() car’s model
int getYear()
car’s model year
String getVIN() car’s vehicle ID
a.
Create an Automobile object named featuredCar
for the Chevrolet described above.
b.
Given an Automobile object named oldCar, write
a line of code to print out the car’s make and model, separated by a space.
System.out.println(
c. Now we want to implement Automobile.java. We know a Automobile must contain its ..., so we make fields for them. Then it needs all the methods of the API. We want encapsulated objects, but can do without toString() to start. Here is a start on Automobile.java. Fill in the missing pieces:
public class Automobile
{
private String make; // make of *this* Automobile--you fill in the other 3 fields
public Automobile(String make0,
) //fill
in
{
make = make0; // you
fill in rest...
}
public String
getMake()
// "getter" method for make
{ return make; } // compact way to
save space
// you fill in other
methods, ending } for class