Advertisement
scaawt

Vehicle

Oct 29th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. /**
  2.  * written by tariq scott
  3.  */
  4.  
  5. public class Vehicle {
  6.  private String manName;
  7.  private int numCyl;
  8.  private String ownName;
  9.  
  10.  public Vehicle ();
  11.  
  12.  //defaults
  13.  {
  14.    manName = "undefined name";
  15.    numCyl = 0;
  16.    ownName = "undefined name";
  17.  }
  18.    
  19.  public Vehicle (String amanName, int anumCyl, String aownName);
  20.  //accesors
  21.    
  22.   public String getmanName()
  23.   {
  24.     return this.manName;
  25.   }
  26.   public int getnumCyl()
  27.   {
  28.     return this.numCyl;
  29.   }
  30.   public String getownName()
  31.   {
  32.     return this.ownName;
  33.   }
  34.  
  35.   //mutators
  36.   public void setmanName(String amanName)
  37.   {
  38.     this.manName = amanName;
  39.   }
  40.   public void setnumCyl (int anumCyl);
  41.   {
  42.     if (anumCyl >= 0);
  43.   {
  44.     this.numCyl = anumCyl;
  45.   }
  46.   }
  47.   public void setownName (String aownName)
  48.   {
  49.     this.ownName = aownName;
  50.   }
  51.  
  52.  
  53.   //other methods
  54.   public String toString()
  55.   {
  56.     return this.manName + " " + this.numCyl + " " + this.ownName;
  57.   }
  58.  
  59.   public boolean equals (Vehicle aVehicle)
  60.   {
  61.     return aVehicle != null &&
  62.     this.manName.equals(aVehicle.getmanName()) &&
  63.     this.numCyl == (aVehicle.getnumCyl()) &&
  64.     this.ownName.equals(aVehicle.getownName());
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement