Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Product implements Buyable {
- private int id;
- private String name;
- private int quantity;
- public Product(int id, String name, int quantity) {
- this.id = id;
- this.name = name;
- this.quantity = quantity;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- @Override
- public int buy(int quantity) {
- return 0;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getQuantity() {
- return quantity;
- }
- public void setQuantity(int quantity) {
- this.quantity = quantity;
- }
- }
- public class BetterProduct extends Product {
- public BetterProduct(int id, String name, int quantity) {
- super(id, name, quantity);
- }
- }
- public class Main {
- public static void main(String[] args) {
- }
- }
- public interface Buyable {
- public int buy(int quantity);
- public String getName();
- }
Advertisement
Add Comment
Please, Sign In to add comment