Define a constructor as indicated. Sample output for below program: Year: 0, VIN: -1 Year: 2009, VIN: 444555666 // ===== Code from file CarRecord.java =====public class CarRecord {private int yearMade;private int vehicleIdNum; // FIXME: Write constructor, initialize year to 0, vehicle ID num to -1. /* Your solution goes here */ public void setYearMade(int originalYear) {yearMade = originalYear;} public void setVehicleIdNum(int vehIdNum) {vehicleIdNum = vehIdNum;} public void print() {System.out.println("Year: " + yearMade + ", VIN: " + vehicleIdNum);}}// ===== end ===== // ===== Code from file CallCarRecord.java =====public class CallCarRecord {public static void main(String [] args) {CarRecord familyCar = new CarRecord(); familyCar.print();familyCar.setYearMade(2009);familyCar.setVehicleIdNum(444555666);familyCar.print(); }}// ===== end =====
Define a constructor as indicated. Sample output for below program:
Year: 0, VIN: -1
Year: 2009, VIN: 444555666
// ===== Code from file CarRecord.java =====
public class CarRecord {
private int yearMade;
private int vehicleIdNum;
// FIXME: Write constructor, initialize year to 0, vehicle ID num to -1.
/* Your solution goes here */
public void setYearMade(int originalYear) {
yearMade = originalYear;
}
public void setVehicleIdNum(int vehIdNum) {
vehicleIdNum = vehIdNum;
}
public void print() {
System.out.println("Year: " + yearMade + ", VIN: " + vehicleIdNum);
}
}
// ===== end =====
// ===== Code from file CallCarRecord.java =====
public class CallCarRecord {
public static void main(String [] args) {
CarRecord familyCar = new CarRecord();
familyCar.print();
familyCar.setYearMade(2009);
familyCar.setVehicleIdNum(444555666);
familyCar.print();
}
}
// ===== end =====
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images