Question
Help with java code public class Vehicle { private String manufacturer; private int cylinders; private String owner; /* TO DO: Create a 3 arg constructor
Help with java code
public class Vehicle
{
private String manufacturer;
private int cylinders;
private String owner;
/*
TO DO:
Create a 3 arg constructor that accepts the variables in the order listed above.
Create a default constructor that calls the 3 arg using this.
Create setters and getters drawing on the names of the variables used above.
(In other words you have no choice for the names of your setters and getters)
Create a toString method that displays all the instance data.
Create an equals method that compares only manufacturer and cylinders.
*/
}
public class Truck ... do something here :)
{
private double payload;
private int towingCapacity;
/*
TO DO:
Create a 5 arg constructor that accepts the variables in the order listed above
- collecting for the needs of the parent and then the needs of the child.
Be sure to use super to call the parent constructor
Create a default constructor that calls the 5 arg using this.
Create setters and getters drawing on the names of the variables used above.
(In other words you have no choice for the names of your setters and getters)
Create a toString method that displays all the instance data.
Call the toString of the parent and tag on to it.
Create an equals method that uses its parents equals methods and then
also compares payload and towingCapacity.
*/
}
Create a main line tester that creates three trucks.
Make sure the data in two of the trucks will test as equal to each other.
Create at least one of the Trucks using the 5 arg constructor
Create at least one of the Trucks using the default constructor and
then calling the setters.
Invoke the equals methods twice on the trucks to prove it tests
true and false correctly.
Display all three trucks at least once by implicitly invoking the toString method
and at least one using only the getters.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started