Okay, a friend helped me and the program is now working. I have reprinted the methods with the correct toPrint() formats below.
HTML Code:
public class vehicleInfo {
public static void main(String[] args) {
//instantiating the objects.
SUV suv1 = new SUV("","silver", "Chevrolet", 5 );
SUV suv2 = new SUV("", "white", "Chevrolet", 5);
Truck truck1 = new Truck("", "green", "Chevrolet", 5);
Truck truck2 = new Truck("", "black", "Chevrolet", 3 );
Car car1 = new Car("", "black", "Chevrolet", 4);
Car car2 = new Car("", "ebony", "Chevrolet", 2);
//printing the information associated with each vehicle object.
suv1.toPrint();
System.out.println();
suv2.toPrint();
System.out.println();
truck1.toPrint();
System.out.println();
truck2.toPrint();
System.out.println();
car1.toPrint();
System.out.println();
car2.toPrint();
System.out.println();
}
}
public class Vehicle {
//instance variables
String VIN;
String color, maker;
//constructors
public Vehicle() {//default constructor
VIN = "";
color = "";
maker = "";
}
public Vehicle(String inVIN, String c, String m) {//constructor with parameters VIN, color and maker.
VIN = inVIN;
color = c;
maker = m;
}
//accessors
public String getVIN() {
return VIN;
}
public String getColor() {
return color;
}
public String getMaker() {
return maker;
}
//mutators
public void setVIN(String inVIN) {
VIN = inVIN;
}
public void setColor(String inColor) {
color = inColor;
}
public void setMaker(String inMaker) {
maker = inMaker;
}
//toString method
/*public String toString() {
String outPut = "The vehicle manufacturer is " + maker + ". It is " + color + " and has VIN number " + VIN + ".";
return outPut;
}*/
//toPrint method.
public void toPrint() {
System.out.println("The vehicle manufacturer is " + maker + ". It is " + color + " and has VIN number " + VIN + ".");
//System.out.println(Vehicle(inVIN, c, m));
}
}
public class PassengerVehicle extends Vehicle {
//instance variable
int numPassengers;
//constructors
public PassengerVehicle() {//default constructor
super();
numPassengers = 0;
}
public PassengerVehicle(String inVIN, String c, String m, int passengersIn) {//constructor with parameters
super(inVIN, c, m);
numPassengers = passengersIn;
}
//accessors
public int getNumPassengers() {
return numPassengers;
}
//mutator
public void setNumPassengers(int passengersIn) {
numPassengers = passengersIn;
}
//toPrint method
public void toPrint() {
super.toPrint();
System.out.println("This vehicle can seat " + numPassengers + " passengers.");
}
}
public class SUV extends PassengerVehicle {
//no instance variables
//constructors
public SUV() {//default constructor
super();
}
public SUV(String inVIN, String c, String m, int passengersIn) {//constructor with parameters.
super(inVIN, c, m, passengersIn);
}
//accessors
//mutators
//toPrint method.
public void toPrint() {
super.toPrint();
}
}