Aktienhandel #4
@ -1,36 +1,34 @@
|
||||
package tech_store;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user