update,
This commit is contained in:
19
_resources/it114105/itp3914/Lab12/Ex1/Item.java
Normal file
19
_resources/it114105/itp3914/Lab12/Ex1/Item.java
Normal file
@@ -0,0 +1,19 @@
|
||||
public class Item {
|
||||
private String productCode;
|
||||
private double price;
|
||||
private int quantity;
|
||||
|
||||
public Item(String productCode, double price, int quantity) {
|
||||
this.productCode = productCode;
|
||||
this.price = price;
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public double getItemTotal() {
|
||||
return price * quantity;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return productCode +":" + price + "*" + quantity + "=" + getItemTotal();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user