Im new to Java programming of course so im having trouble with this program i have to write
Can anyone give me some tips on inheritance?
public class Trailer
{
public Trailer(String anID)
{
trailerID = anID;
}
public Trailer getNextTrailer()
{
return nextTrailer;
}
public void setNextTrailer(Trailer newTrailer)
{
nextTrailer = newTrailer;
}
public void loadGood(Goods aGoods)
{
}
public double getValue()
{
double value;
value = theGood.getValue();
return value;
}
public void display()
{
System.out.println("Trailer " + trailerID + theGood.getDescription());
}
private String trailerID;
private Trailer nextTrailer;
private Goods theGood;
}
public class Truck
{
public Truck(Driver aDriver, String aTruckID)
{
theDriver = aDriver;
truckID = aTruckID;
totalValue = 0.0;
}
public void connectTrailer(Trailer aTrailer)
{
}
public void displayInformation()
{
System.out.println("Information on Truck " + truckID + ":");
System.out.println("Driver is " + theDriver);
System.out.println(display());
System.out.println("The total value of the goods on the truck is $");
}
private String truckID;
private Driver theDriver;
private Trailer firstTrailer;
private double totalValue;
}
I have other classes which inherit each other but they arn't the problem
The problem is with the system.out.println parts as the error says
Trailer.java:39: 'void' type not allowed here
System.out.println("Trailer " + trailerID + theGood.getDescription());
^
1 error
Why arn't i aloud to put a 'void' method in an output??