Advertisement
brilliant_moves

Vehicle.java

Dec 1st, 2013
1,164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.86 KB | None | 0 0
  1. /*
  2.  
  3. Asked by KJ on Yahoo! Answers 01.12.2013:
  4.  
  5. "Write an abstract superclass encapsulating a vehicle:
  6.  
  7. A vehicle has two attributes: its owner's name and its number of wheels.
  8.  This class has two non-abstract subclasses: one encapsulating a bicycle, and
  9.  the other encapsulating a motorized vehicle. A motorized vehicle has the following
  10.  additional attributes: its engine volume displacement, in liters; and a method computing
  11.  and returning a measure of horsepower which is the number of liters times the number of
  12.  wheels. You also need to include a client class to test these two classes."
  13.  
  14. */
  15.  
  16. public abstract class Vehicle {
  17.  
  18.     private String ownerName;
  19.     private int numWheels;
  20.  
  21.     public Vehicle() {} // default constructor
  22.  
  23.     public Vehicle(String name, int wheels) { // overloaded constructor
  24.         this.ownerName = name;
  25.         this.numWheels = wheels;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement