public class Vehicle { private String manufacturer; private int cylinders; private String owner; /* TO DO: Create
Question:
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.
Starting Out With Java From Control Structures Through Data Structures
ISBN: 9780133957051
6th Edition
Authors: Tony Gaddis