scaawt

Truck

Oct 29th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. /**
  2.  * written by tariq scott
  3.  */
  4. public class Truck extends Vehicle{ //so i dont have to recreate the same verbs
  5.   private double loadCap;
  6.   private double towCap;
  7.  
  8.   public Truck()
  9.   {
  10.     super();
  11.     loadCap = 0.0; //both of these variables are indicating no number at the moment
  12.     towCap = 0.0;
  13.   }
  14.  
  15.   public Truck (double aloadCap, double atowCap)
  16.   {
  17.     super (manName, numCyl, ownName);
  18.     this.setloadCap(aloadCap);
  19.     this.settowCap(atowCap);
  20.   }
  21.  
  22.   //accessors
  23.   public double getloadCap ();
  24.   {
  25.     return this.loadCap;
  26.   }
  27.   public double gettowCap () ;
  28.   {
  29.     return this.towCap;
  30.   }
  31.  
  32.   //mutators
  33.   public void setloadCap(double aloadCap)
  34.   {
  35.     if (loadCap >= 0)
  36.     {
  37.       this.loadCap = aloadCap;
  38.     }
  39.   }
  40.   public void settowCap(double atowCap)
  41.   {
  42.    if (towCap >= 0)
  43.     {
  44.      this.towCap = atowCap;
  45.    }
  46.   }
  47.  
  48.   //other methods
  49.   public String toString ()
  50.   {
  51.     return super.toString() + "\t " + this.loadCap + " " + this.towCap + " ";
  52.   }
  53.   public boolean equals(Truck aTruck)
  54.   {
  55.     return aTruck != null &&
  56.       super.equals(aTruck) &&
  57.       this.loadCap == aTruck.getloadCap() &&
  58.       this.towCap == aTruck.gettowCap();
  59.   }  
  60. }
Add Comment
Please, Sign In to add comment