Advertisement
Sheero

ParkedCar

May 17th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 KB | None | 0 0
  1. //Zehra Baig
  2. //CSC-236-C1
  3. //Lab 1-A
  4.  
  5. public class ParkedCar
  6. {
  7.     //Fields
  8.     private String make;
  9.     private int model;
  10.     private String color;
  11.     private String licenseNumber;
  12.     private int minutesParked;
  13.    
  14.     //Default Constructor
  15.     public ParkedCar()
  16.     {
  17.         this("", 0, "", "", 0);
  18.     }
  19.    
  20.     //Overloaded Constructor
  21.     public ParkedCar(String m, int md, String c, String ln, int mp)
  22.     {
  23.         make = m;
  24.         model = md;
  25.         color = c;
  26.         licenseNumber = ln;
  27.         minutesParked = mp;
  28.     }
  29.    
  30.     //Sets make of ParkedCar obj, accepts String as arg
  31.     public void setMake(String m)
  32.     {
  33.         make = m;
  34.     }
  35.  
  36.     //Sets model of ParkedCar obj, accepts int as arg
  37.     public void setModel(int md)
  38.     {
  39.         model = md;
  40.     }
  41.  
  42.     //Sets color of ParkedCar obj, accepts String as arg
  43.     public void setColor(String c)
  44.     {
  45.         color = c;
  46.     }
  47.  
  48.     //Sets license plate of ParkedCar obj, accepts String as arg
  49.     public void setLicenseNumber(String ln)
  50.     {
  51.         licenseNumber = ln;
  52.     }
  53.  
  54.     //Sets minutes parked of ParkedCar obj, accepts int as arg
  55.     public void setMinutesParked(int mp)
  56.     {
  57.         minutesParked = mp;
  58.     }
  59.  
  60.     //Retrieves and returns make of ParkedCar obj
  61.     public String getMake()
  62.     {
  63.         return make;
  64.     }
  65.  
  66.     //Retrieves and returns model of ParkedCar obj
  67.     public int getModel()
  68.     {
  69.         return model;
  70.     }
  71.  
  72.     //Retrieves and returns color of ParkedCar obj
  73.     public String getColor()
  74.     {
  75.         return color;
  76.     }
  77.  
  78.     //Retrieves and returns license number of ParkedCar obj
  79.     public String getLicenseNumber()
  80.     {
  81.         return licenseNumber;
  82.     }
  83.  
  84.     //Retrieves and returns minutes parked of ParkedCar obj
  85.     public int getMinutesParked()
  86.     {
  87.         return minutesParked;
  88.     }
  89.    
  90.     //Overridden toString() method
  91.     public String toString()
  92.     {
  93.         return "Make: " + this.getMake()
  94.              + "\nModel: " + this.getModel()
  95.              + "\nColor: " + this.getColor()
  96.              + "\nLicense Number: " + this.getLicenseNumber()
  97.              + "\nMinutes Parked: " + this.getMinutesParked() + " minutes";
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement