desislava_topuzakova

03.Parking -> class Car

Jun 10th, 2021
684
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package parking;
  2.  
  3. public class Car {
  4.     //fields
  5.     private String manufacturer;
  6.     private String model;
  7.     private int year;
  8.  
  9.     //constructor
  10.     public Car(String manufacturer, String model, int year) {
  11.         this.manufacturer = manufacturer;
  12.         this.model = model;
  13.         this.year = year;
  14.     }
  15.  
  16.     public String getManufacturer() {
  17.         return manufacturer;
  18.     }
  19.  
  20.     public void setManufacturer(String manufacturer) {
  21.         this.manufacturer = manufacturer;
  22.     }
  23.  
  24.     public String getModel() {
  25.         return model;
  26.     }
  27.  
  28.     public void setModel(String model) {
  29.         this.model = model;
  30.     }
  31.  
  32.     public int getYear() {
  33.         return year;
  34.     }
  35.  
  36.     public void setYear(int year) {
  37.         this.year = year;
  38.     }
  39.  
  40.     @Override
  41.     public String toString() {
  42.         //"{manufacturer} {model} ({year})"
  43.         return String.format("%s %s (%d)", getManufacturer(), getModel(), getYear());
  44.     }
  45. }
  46.  
RAW Paste Data