Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package CarSalesman;
- public class Car {
- private String model;
- private String engine;
- private int weight;
- private String color;
- public Car(String model,String engine){
- this.model=model;
- this.engine=engine;
- this.weight=0;
- this.color="n/a";
- }
- public Car(String model,String engine,int weight){
- this(model,engine);
- this.weight=weight;
- }
- public Car(String model,String engine,String color){
- this(model,engine);
- this.color=color;
- }
- public Car(String model,String engine,int weight,String color){
- this(model,engine,weight);
- this.color=color;
- }
- public String getModel(){
- return this.model;
- }
- public String getEngine(){
- return this.engine;
- }
- public String getColor(){
- return this.color;
- }
- public String printed(){
- if(this.weight==0){
- return String.format("n/a");
- }
- return String.format("%d",this.weight);}
- }
Add Comment
Please, Sign In to add comment