Advertisement
Tsuki11

Class Car

Mar 11th, 2020
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. package MoreExercise_3_CarSalesman;
  2.  
  3. public class Car {
  4.  
  5.     public String getCarModel() {
  6.         return carModel;
  7.     }
  8.  
  9.     public Engine getEngine() {
  10.         return engine;
  11.     }
  12.  
  13.     public String getCarWeight() {
  14.         return carWeight;
  15.     }
  16.  
  17.     public String getCarColour() {
  18.         return carColour;
  19.     }
  20.     @Override
  21.     public String toString() {
  22.         return String.format("\n" +
  23.                 "%s\n" +
  24.                 "Weight: %s\n" +
  25.                 "Color: %s",  this.engine, this.carWeight, this.carColour);
  26.  
  27.     }
  28.  
  29.     public Car(String carModel, Engine engine, String carWeight, String carColour) {
  30.         this.carModel = carModel;
  31.         this.engine = engine;
  32.         this.carWeight = carWeight;
  33.         this.carColour = carColour;
  34.     }
  35.  
  36.     private String carModel;
  37.     private Engine engine;
  38.     private String carWeight;
  39.     private String carColour;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement