jwrbg

Untitled

Jun 9th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. package CarSalesman;
  2.  
  3. public class Car {
  4.     private String model;
  5.     private String engine;
  6.     private int weight;
  7.     private String color;
  8.  
  9.     public Car(String model,String engine){
  10.         this.model=model;
  11.         this.engine=engine;
  12.         this.weight=0;
  13.         this.color="n/a";
  14.     }
  15.     public Car(String model,String engine,int weight){
  16.         this(model,engine);
  17.         this.weight=weight;
  18.     }
  19.     public Car(String model,String engine,String color){
  20.         this(model,engine);
  21.         this.color=color;
  22.     }
  23.     public Car(String model,String engine,int weight,String color){
  24.         this(model,engine,weight);
  25.         this.color=color;
  26.     }
  27.     public String getModel(){
  28.         return this.model;
  29.     }
  30.     public String getEngine(){
  31.         return this.engine;
  32.     }
  33.     public String getColor(){
  34.         return this.color;
  35.     }
  36.     public String printed(){
  37.         if(this.weight==0){
  38.             return String.format("n/a");
  39.         }
  40.     return String.format("%d",this.weight);}
  41. }
Add Comment
Please, Sign In to add comment