Valeri173

Untitled

Apr 13th, 2021
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. public class Product implements Buyable {
  2. private int id;
  3. private String name;
  4. private int quantity;
  5.  
  6. public Product(int id, String name, int quantity) {
  7. this.id = id;
  8. this.name = name;
  9. this.quantity = quantity;
  10. }
  11.  
  12. public int getId() {
  13. return id;
  14. }
  15.  
  16. public void setId(int id) {
  17. this.id = id;
  18. }
  19.  
  20. @Override
  21. public int buy(int quantity) {
  22. return 0;
  23. }
  24.  
  25. public String getName() {
  26. return name;
  27. }
  28.  
  29. public void setName(String name) {
  30. this.name = name;
  31. }
  32.  
  33. public int getQuantity() {
  34. return quantity;
  35. }
  36.  
  37. public void setQuantity(int quantity) {
  38. this.quantity = quantity;
  39. }
  40. }
  41.  
  42. public class BetterProduct extends Product {
  43.  
  44. public BetterProduct(int id, String name, int quantity) {
  45. super(id, name, quantity);
  46. }
  47. }
  48.  
  49. public class Main {
  50. public static void main(String[] args) {
  51.  
  52. }
  53. }
  54.  
  55. public interface Buyable {
  56. public int buy(int quantity);
  57. public String getName();
  58. }
Advertisement
Add Comment
Please, Sign In to add comment