forked from denyskon/info-java
35 lines
820 B
Java
Executable File
35 lines
820 B
Java
Executable File
public class Product {
|
|
private int productID;
|
|
private String productName;
|
|
private int productPrice;
|
|
private int productAmount;
|
|
public Product(int id, String name, int price, int amt) {
|
|
this.productID = id;
|
|
this.productName = name;
|
|
this.productPrice = price;
|
|
this.productAmount = amt;
|
|
}
|
|
public int getID() {
|
|
return this.productID;
|
|
}
|
|
public String getName() {
|
|
return this.productName;
|
|
}
|
|
public int getPrice() {
|
|
return this.productPrice;
|
|
}
|
|
public int getAmount() {
|
|
return this.productAmount;
|
|
}
|
|
public void reduceAmount(int amt) {
|
|
if (this.productAmount < amt) {
|
|
System.out.println("Not enough of product " + this.productID + "(" + this.productName + ") available!");
|
|
return;
|
|
}
|
|
this.productAmount -= amt;
|
|
}
|
|
public void increaseAmount(int amt) {
|
|
this.productAmount += amt;
|
|
}
|
|
}
|