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;
}
}
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: