Guest User

Untitled

a guest
Feb 4th, 2022
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. public class Car {
  2.  
  3.     /**
  4.      * Instance variable for storing the type of the car
  5.      */
  6.     private CarType type;
  7.  
  8.     /**
  9.      * Instance variable for storing the car plate number
  10.      */
  11.     private String plateNum;
  12.  
  13.     /**
  14.      * @return the type of this car
  15.      */
  16.     public CarType getType() {
  17.         // WRITE YOUR CODE HERE!
  18.    
  19.         return this.type; // REMOVE THIS STATEMENT AFTER IMPLEMENTING THIS METHOD*
  20.     }
  21.  
  22.     /**
  23.      * Sets the type of the car
  24.      *
  25.      * @param type is the car type
  26.      */
  27.     public void setType(CarType type) {
  28.         // WRITE YOUR CODE HERE!
  29.         this.type = type;
  30.     }
  31.  
  32.     /**
  33.      * @return the plate number
  34.      */
  35.     public String getPlateNum() {
  36.         // WRITE YOUR CODE HERE!
  37.        
  38.         return plateNum; // REMOVE THIS STATEMENT AFTER IMPLEMENTING THIS METHOD*
  39.     }
  40.  
  41.     /**
  42.      * Sets the car plate number
  43.      *
  44.      * @param plateNum is the car plate number
  45.      */
  46.     public void setPlateNum(String plateNum) {
  47.     // WRITE YOUR CODE HERE!
  48.     this.plateNum = plateNum;
  49.     }
  50.  
  51.     /**
  52.      * Constructor for Car
  53.      *
  54.      * @param type     is the type of the car
  55.      * @param plateNum is the car plate number
  56.      */
  57.     public Car(CarType type, String plateNum) {
  58.     // WRITE YOUR CODE HERE!
  59.     this.type = type;
  60.         this.plateNum = plateNum;
  61.     }
  62.  
  63.     /**
  64.      * Returns a string representation of the car
  65.      */
  66.     public String toString() {
  67.         // NOTE: The implementation of this method is complete. You do NOT need to
  68.         // change it for the assignment.
  69.         return Util.getLabelByCarType(type) + '(' + plateNum + ')';
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment