Advertisement
desislava_topuzakova

05.CarSalesman_Car

Oct 5th, 2020
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. package CarSalesman_05;
  2.  
  3. public class Car {
  4.     //model, engine, weight and color
  5.     private String model;
  6.     private String engineModel;
  7.     //optional
  8.     private int weight;
  9.     private String color;
  10.  
  11.     //1. начин -> model, engineModel
  12.     //2. начин -> model, engineModel, weight, color
  13.     //3. начин -> model, engineModel, weight
  14.     //3. начин -> model, engineModel, color
  15.  
  16.     public Car (String model, String engineModel) {
  17.         this.model = model;
  18.         this.engineModel = engineModel;
  19.         this.weight = 0;
  20.         this.color = "n/a";
  21.     }
  22.  
  23.     public Car (String model, String engineModel, int weight, String color) {
  24.         this(model, engineModel);
  25.         this.weight = weight;
  26.         this.color = color;
  27.     }
  28.  
  29.     public Car (String model, String engineModel, int weight) {
  30.         this(model, engineModel);
  31.         this.weight = weight;
  32.         this.color = "n/a";
  33.     }
  34.  
  35.     public Car (String model, String engineModel, String color) {
  36.         this(model, engineModel);
  37.         this.color = color;
  38.         this.weight = 0;
  39.     }
  40.  
  41.     public String getModel() {
  42.         return this.model;
  43.     }
  44.  
  45.     public String getEngineModel() {
  46.         return this.engineModel;
  47.     }
  48.  
  49.     public int getWeight() {
  50.         return this.weight;
  51.     }
  52.  
  53.     public String getColor() {
  54.         return this.color;
  55.     }
  56.  
  57.     public static String getFullName() {
  58.         return "Test";
  59.     }
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement