return a string with a message when a constructor is executed

Joined
Oct 17, 2008
Messages
2
Reaction score
0
With the method checkTaxStatus how can I output these message when the constructor is executed than call the method?.

public Car(String companyMake,String modelName,int milesPerGallon,int listPrice)
{
// initialise instance variables
make = companyMake;
model = modelName;
miles = milesPerGallon;
price = listPrice;
milometer = 0;
services = 0;
regNum = null;
name = null;
ownersNum = 0;
taxes = "taxes included";
notaxes= "no taxes";
}

* Return miles per gallon.
*/
public int getMiles()
{
return miles;
}

public String checkTaxStatus()
{
if(miles < 64 ){
return taxes;
}
else {
return notaxes;
}

}
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,076
Messages
2,570,565
Members
47,201
Latest member
IvyTeeter

Latest Threads

Top