当前位置:首页 > ssd3 实验完整答案 一、二
if (size == 0) {
stdErr.println(\ } else {
for (Product product : this.catalog) {
stdOut.println(product.getCode() + \product.getDescription()); } } } /**
* Displays the information of a product */
public void displayProductInfo() throws IOException {
Product product = readProduct();
stdOut.println(\stdOut.println(\if (product instanceof Coffee) {
Coffee coffee = (Coffee) product;
stdOut.println(\stdOut.println(\stdOut.println(\stdOut.println(\stdOut.println(\stdOut.println(\ } else if (product instanceofCoffeeBrewer) {
CoffeeBrewer brewer = (CoffeeBrewer) product;
stdOut.println(\
stdOut.println(\stdOut.println(\ } } /**
* Displays the current order. */
public void displayOrder() {
int size = this.currentOrder.getNumberOfItems();
if (size == 0) {
stdErr.println(\ } else {
for (OrderItemorderItem : this.currentOrder) { stdOut.println(orderItem.toString()); }
stdOut.println(\
CURRENCY.format(this.currentOrder.getTotalCost())); } } /**
* Modifies the current order: if the specified product is not already * part of the order, it is added; otherwise, the quantity of the * specified product is updated. */
public void addModifyProduct() throws IOException {
Product product = readProduct();
int quantity = readQuantity();
OrderItemorderItem = this.currentOrder.getItem(product);
if (orderItem == null) {
this.currentOrder.addItem(new OrderItem(product, quantity)); stdOut.println(\ + \ } else {
orderItem.setQuantity(quantity);
stdOut.println(\product.getCode() + \ } } /**
* Removes a product from the current order. */
public void removeProduct() throws IOException {
Product product = readProduct();
OrderItemorderItem = this.currentOrder.getItem(product);
共分享92篇相关文档