Question: //Class Id : Vehicle.java - Inheritance question public class Vehicle { protected String vin; //vehicle ID number public Vehicle( ) { vin = Unknown; }

//Class Id : Vehicle.java - Inheritance question public class Vehicle { protected String vin; //vehicle ID number public Vehicle( ) { vin = "Unknown"; } public Vehicle(String someVin) { vin = someVin; } public String getVin( ) { return vin; } public void setVin(String someVin) { vin = someVin; } public String toString( ) { return("vin: " + vin); } }//end of class Vehicle
(17 pts) Inheritance. Write a complete Truck class based on the UML provided. The Truck class is a subclass of the Vehicle class. The Vehicle class is listed on the last page of this exam. Your Truck implementation must utilize inheritance features 8. Truck -weight:int +Iruck() //the weight of a truck //constructor. default weight -e +Truck (somevin:string, wint) //constructor. Initialize vin to someVin, weight to w +setweight(w:int):void +hasweightviolation(maxweight:int):boolean //set the truck's weight to positive weights only //otherwise the weight does not change //return true if a truck's weight is greater than maxleight. Otherwise return false. tostring):string /Ireturns current state of a truck's instance variables
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
