Question: JAVA 1. Create a base class called Vehicle that has the manufacturer's name (type String), number of cylinders in the engine (type int), and owner
JAVA
1.Create a base class called Vehicle that has the manufacturer's name (type String), number of cylinders in the engine (type int), and owner (type Class Person), then create a class called Truck that is derived from Vehicle and has additional properties: the load capacity in tons (type double, since it may contain a fractional part) and towing capacity in tons (type double). Give your classes a reasonable complement of constructors and accessor methods, and an equals method to test whether two Vehicle or Truck is equal or no based on its properties as well. Write a driver program that tests all your methods.
Person class has name, age, address, gender and weight attributes and showInfo method that prints out the information of the current Person
2.Create a new class called Cow that is derived from the Animal class. The new class has the additional attribute of milk (type double). Give your classes a reasonable complement of constructors and accessor methods in addition to showInfo method which show Cow details. Write a driver program to test all your methods, then write a program that reads in five Animals of type Cow and displays the id, weight and milk of all cows.
Animal class has weight and Id attributes.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
