Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Asked by KJ on Yahoo! Answers 01.12.2013:
- "Write an abstract superclass encapsulating a vehicle:
- A vehicle has two attributes: its owner's name and its number of wheels.
- This class has two non-abstract subclasses: one encapsulating a bicycle, and
- the other encapsulating a motorized vehicle. A motorized vehicle has the following
- additional attributes: its engine volume displacement, in liters; and a method computing
- and returning a measure of horsepower which is the number of liters times the number of
- wheels. You also need to include a client class to test these two classes."
- */
- public abstract class Vehicle {
- private String ownerName;
- private int numWheels;
- public Vehicle() {} // default constructor
- public Vehicle(String name, int wheels) { // overloaded constructor
- this.ownerName = name;
- this.numWheels = wheels;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement