Subclass toString should call include super.toString();re-submit these codes. public class Vehicle {    private String registrationNumber;    private String ownerName;    private double price;    private int yearManufactured;    Vehicle [] myVehicles = new Vehicle[100];      public Vehicle() {        registrationNumber="";        ownerName="";        price=0.0;        yearManufactured=0;    }    public Vehicle(String registrationNumber, String ownerName, double price, int yearManufactured) {        this.registrationNumber=registrationNumber;        this.ownerName=ownerName;        this.price=price;        this.yearManufactured=yearManufactured;    }    public String getRegistrationNumber() {        return registrationNumber;    }    public String getOwnerName() {        return ownerName;    }    public double getPrice() {        return price;    }    public int getYearManufactured() {        return yearManufactured;    }    public void setRegistrationNumber(String registrationNumber) {        this.registrationNumber=registrationNumber;    }    public void setOwnerName(String ownerName) {        this.ownerName=ownerName;    }    public void setPrice(double price) {        this.price=price;    }    public void setYearManufactured(int yearManufactured) {        this.yearManufactured=yearManufactured;    }      public String toString() {        return " Registration number:"+ registrationNumber +"\n Owner Name:"+ownerName+"\n Price:"+    price+"\n year manufactured"+yearManufactured;    } public static double findMin(Vehicle[] theVehicles) {    double lowestPrice = Vehicles[0];    for(int i=1; i<price.length;i++){    if(Vehicles[i] < lowestPrice){        lowestPrice = Vehicles[i];        }     }    return lowestPrice; }  public class Car extends Vehicle{    private int numberOfDoors;     public Car(String registrationNumber, String ownerName, double price, int yearManufactured, int numberOfDoors) {        super(registrationNumber, ownerName, price, yearManufactured);        this.numberOfDoors = numberOfDoors;    }     public int getNumberOfDoors() {        return numberOfDoors;    }     @Override    public String toString() {        return "Car{" +                "numberOfDoors=" + numberOfDoors +                '}';    }     public void setNumberOfDoors(int numberOfDoors) {        this.numberOfDoors = numberOfDoors;    }}public class Truck extends Vehicle{    private int numberOfAxles;     public Truck(String registrationNumber, String ownerName, double price, int yearManufactured, int numberOfAxles) {        super(registrationNumber, ownerName, price, yearManufactured);        this.numberOfAxles = numberOfAxles;    }     public int getNumberOfAxles() {        return numberOfAxles;    }     public void setNumberOfAxles(int numberOfAxles) {        this.numberOfAxles = numberOfAxles;    }     @Override    public String toString() {        return "Truck{" +                "numberOfAxles=" + numberOfAxles +                '}';    }}

Question
Asked Nov 4, 2019
21 views

Subclass toString should call include super.toString();

re-submit these codes.

 

public class Vehicle {

 

   private String registrationNumber;

 

   private String ownerName;

 

   private double price;

 

   private int yearManufactured;

 

   Vehicle [] myVehicles = new Vehicle[100];

 

 

 

   public Vehicle() {

 

       registrationNumber="";

 

       ownerName="";

 

       price=0.0;

 

       yearManufactured=0;

 

   }

 

   public Vehicle(String registrationNumber, String ownerName, double price, int yearManufactured) {

 

       this.registrationNumber=registrationNumber;

 

       this.ownerName=ownerName;

 

       this.price=price;

 

       this.yearManufactured=yearManufactured;

 

   }

 

   public String getRegistrationNumber() {

 

       return registrationNumber;

 

   }

 

   public String getOwnerName() {

 

       return ownerName;

 

   }

 

   public double getPrice() {

 

       return price;

 

   }

 

   public int getYearManufactured() {

 

       return yearManufactured;

 

   }

 

   public void setRegistrationNumber(String registrationNumber) {

 

       this.registrationNumber=registrationNumber;

 

   }

 

   public void setOwnerName(String ownerName) {

 

       this.ownerName=ownerName;

 

   }

 

   public void setPrice(double price) {

 

       this.price=price;

 

   }

 

   public void setYearManufactured(int yearManufactured) {

 

       this.yearManufactured=yearManufactured;

 

   }

 

 

 

   public String toString() {

 

       return " Registration number:"+ registrationNumber +"\n Owner Name:"+ownerName+"\n Price:"+

 

   price+"\n year manufactured"+yearManufactured;

 

   }

 

public static double findMin(Vehicle[] theVehicles)

 

{

 

   double lowestPrice = Vehicles[0];

 

   for(int i=1; i<price.length;i++){

 

   if(Vehicles[i] < lowestPrice){

 

       lowestPrice = Vehicles[i];

 

       } 

 

   }

 

   return lowestPrice;

 

}

 

 

public class Car extends Vehicle{

    private int numberOfDoors;

 

    public Car(String registrationNumber, String ownerName, double price, int yearManufactured, int numberOfDoors) {

        super(registrationNumber, ownerName, price, yearManufactured);

        this.numberOfDoors = numberOfDoors;

    }

 

    public int getNumberOfDoors() {

        return numberOfDoors;

    }

 

    @Override

    public String toString() {

        return "Car{" +

                "numberOfDoors=" + numberOfDoors +

                '}';

    }

 

    public void setNumberOfDoors(int numberOfDoors) {

        this.numberOfDoors = numberOfDoors;

    }

}

public class Truck extends Vehicle{

    private int numberOfAxles;

 

    public Truck(String registrationNumber, String ownerName, double price, int yearManufactured, int numberOfAxles) {

        super(registrationNumber, ownerName, price, yearManufactured);

        this.numberOfAxles = numberOfAxles;

    }

 

    public int getNumberOfAxles() {

        return numberOfAxles;

    }

 

    public void setNumberOfAxles(int numberOfAxles) {

        this.numberOfAxles = numberOfAxles;

    }

 

    @Override

    public String toString() {

        return "Truck{" +

                "numberOfAxles=" + numberOfAxles +

                '}';

    }

}

 

check_circle

Expert Answer

Step 1

Program Modifications:

Add the super.toString() call with the other print statements in the toString() method...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Engineering

Programing

Related Computer Engineering Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: what are the mantissa and exponent value if 6.75 is represented in 8 bit binary floating point repre...

A: The mantissa and exponent value if 6.75 is represented in 8 bit binary floating point representation...

question_answer

Q: Provide a physical block diagram for a concept of an autonomous transportation and/or delivery that ...

A: Autonomous Vehicle Hardware:The hardware components allow the car to complete such tasks as seeing t...

question_answer

Q: Could you help me with this question. This course is Programming 1. This is the question, "A custome...

A: Question is asking about to calculate the total, subtotal and the sale Tax of the 5 items purchase f...

question_answer

Q: Use Eclipse for this program

A:  Step 1: Import required package.Step 2: Define “AnalyzeNumbers” class.Step 3: Define main function....

question_answer

Q: Hello, I am trying to write a program: Write a .py file like MainFiles.py In that .py, create a func...

A: A python file is created named as MainFiles.py:Def main( ):Print(“ Welcome to python”)The above pyth...

question_answer

Q: Based on Program.Py below, develop a list of requirements that could have been used to create the or...

A: Requirements are statements or items that shall be used or that a system needs while writing a progr...

question_answer

Q: Problem: Write a program that converts degrees from Celsius to Fahrenheit, using the formula:Degrees...

A: Since you have asked two separate questions and it was not clear which specific question you wanted ...

question_answer

Q: Write a program that prompts the user to enter the weight of a person in kilograms and outputs the e...

A: AlgorithmPrompt the user to enter weight in kilogramsAccept the user inputCovert the weight in kilog...

question_answer

Q: Imagine you’d like a contractor to build a software application for you that operates like Windows C...

A: Statement of objectives (SOO):It provides an overall objective which serves as the basis for the sta...