Advertisement
Guest User

Vegetable

a guest
Oct 23rd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. package healthyHeaven;
  2.  
  3. public class Vegetable {
  4.     private String name;
  5.     private int calories;
  6.  
  7.     public Vegetable(String name, int calories) {
  8.         this.name = name;
  9.         this.calories = calories;
  10.     }
  11.  
  12.     public String getName() {
  13.         return name;
  14.     }
  15.  
  16.     public int getCalories() {
  17.         return calories;
  18.     }
  19.  
  20.     @Override
  21.     public String toString() {
  22.         return String.format(" - %s have %d calories%n",this.name,this.calories);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement