Advertisement
purshink

Present

Jun 26th, 2020
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. package christmas;
  2.  
  3. public class Present {
  4.  
  5.     private String name;
  6.     private String gender;
  7.     private Double weight;
  8.  
  9.     public Present(String name, Double weight, String gender) {
  10.         this.name = name;
  11.         this.gender = gender;
  12.         this.weight = weight;
  13.     }
  14.  
  15.     public String getName() {
  16.         return name;
  17.     }
  18.  
  19.     public String getGender() {
  20.         return gender;
  21.     }
  22.  
  23.     public Double getWeight() {
  24.         return weight;
  25.     }
  26.  
  27.     @Override
  28.     public String toString() {
  29.         return "Present " + this.getName() + " (" + String.format("%.2f",this.getWeight()) + ") for a " +this.getGender().trim();
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement