Guest User

Untitled

a guest
Jun 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. public class GroceryItem implements Carryable {
  2. String name;
  3. float price;
  4. float weight; // in kg
  5.  
  6. public GroceryItem (String n, float p, float w){
  7. name = n;
  8. price = p;
  9. weight = w;
  10. }
  11.  
  12. public GroceryItem[] getContents(){
  13. return new GroceryItem[0];
  14. }
  15.  
  16. public String getDescription(){
  17. return name;
  18.  
  19. }
  20.  
  21. public float getPrice(){
  22. return price;
  23.  
  24. }
  25. public String toString(){
  26. return name + "weighing" + weight + "kg with price" + price;
  27.  
  28. }
  29.  
  30. }
Add Comment
Please, Sign In to add comment