info-java/Technikladen/Product.java
Igor Bartkowski 89bb3a674e TechStore code (#1)
Technikladen-Aufgaben-Lösung hinzugefügt, weitere kleinere Änderungen werden noch folgen, aber funktional hiermit vollständig

Reviewed-on: denyskon/info-java#1
Reviewed-by: Denys Konovalov <kontakt@denyskon.de>
Co-authored-by: ibartkowski <ibartkowski@git.cantorgymnasium.de>
Co-committed-by: ibartkowski <ibartkowski@git.cantorgymnasium.de>
2024-10-14 19:12:15 +02:00

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;
}
}