Advertisement
scaawt

Car

Oct 29th, 2018
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. /**
  2.  * Auto Generated Java Class.
  3.  */
  4. public class Car extends Vehicle {
  5.  
  6.   private double gas;
  7.   private int passengers;
  8.    
  9.   public Car()
  10.   {
  11.     super ();
  12.     gas = 0.0;
  13.     passengers = 0;  
  14.   }
  15.  
  16.   public Car (double aGas, int aPassengers)
  17.   {
  18.     super (manName, numCyl, ownName);
  19.     this.setGas(aGas);
  20.     this.setPassengers(aPassengers);
  21.   }
  22.  
  23.   //accessors
  24.   public double getGas()
  25.   {
  26.     return this.gas;
  27.   }
  28.   public int getPassengers()
  29.   {
  30.     return this.passengers;
  31.   }
  32.  
  33.   //mutators
  34.   public void setGas(double aGas)
  35.   {
  36.     if (gas >= 0)
  37.   {
  38.     return this.gas;
  39.   }
  40.   }
  41.   public void setPassengers (int aPassengers)
  42.   {
  43.     if (passengers >= 0)
  44.     {
  45.       return this.passengers;
  46.     }
  47.   }
  48.  
  49.  
  50.  //other methods
  51.   public String toString ()
  52.   {
  53.     return super.toString() + "\a " + this.gas + " " + this.passengers + " ";
  54.   }
  55.     public boolean equals (Car aCar)
  56.   {
  57.       return aCar != null &&
  58.         super.equals(aCar) &&
  59.         this.gas == aCar.getGas () &&
  60.         this.passengers == aCar.getPassengers();
  61.   }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement