RGAlex

Vehicle

Feb 21st, 2021
1,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. package Exercise.O6Exercise;
  2.  
  3. public class Vehicle {
  4.     private String type;
  5.     private String model;
  6.     private String color;
  7.     private int horsePower;
  8.  
  9.     public String getType() {
  10.         return type;
  11.     }
  12.  
  13.     public void setType(String type) {
  14.         this.type = type;
  15.     }
  16.  
  17.     public String getModel() {
  18.         return model;
  19.     }
  20.  
  21.     public void setModel(String model) {
  22.         this.model = model;
  23.     }
  24.  
  25.     public String getColor() {
  26.         return color;
  27.     }
  28.  
  29.     public void setColor(String color) {
  30.         this.color = color;
  31.     }
  32.  
  33.     public int getHorsePower() {
  34.         return horsePower;
  35.     }
  36.  
  37.     public void setHorsePower(int horsePower) {
  38.         this.horsePower = horsePower;
  39.     }
  40.  
  41.     @Override
  42.     public String toString() {
  43.         return String.format("Type: %s\n" +
  44.                 "Model: %s\n" +
  45.                 "Color: %s\n" +
  46.                 "Horsepower: %d", getType().toUpperCase().charAt(0) + this.getType().substring(1), getModel(), getColor(), getHorsePower());
  47.     }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment