Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. class Product {
  2. private String name; //Название товара
  3. private int price; // Цена товара
  4.  
  5. //конструктор
  6. public Product (String name, int price) {
  7. this.name = name;
  8. this.price = price;
  9. }
  10.  
  11. public String getName() {
  12. return name;
  13. }
  14.  
  15. public int getPrice() {
  16. return price;
  17. }
  18.  
  19. public void setName(String name) {
  20. this.name = name;
  21. }
  22.  
  23. public void setPrice (int price) {
  24. this.price = price;
  25. }
  26.  
  27. @Override
  28. public String toString() {
  29. return "Название = "+name+" Стоимость = "+price;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement