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 +
'}';
}
}
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...
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...
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...
Q: Use Eclipse for this program
A: Step 1: Import required package.Step 2: Define “AnalyzeNumbers” class.Step 3: Define main function....
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...
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...
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 ...
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...
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...