ssd3 实验完整答案 一、二

loading 分享 2026-8-24 下载文档

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


ssd3 实验完整答案 一、二.doc 将本文的Word文档下载到电脑
搜索更多关于: ssd3 实验完整答案 一、二 的文档
相关推荐
相关阅读