CECS 277
LAB ASSIGNMENT 8
Assigned date: 11/6
Due date: 12/2

30 points

1. Design a ordering system application using visitor pattern.

The customer can order the following items:

Write a main method that accepts the customer orders, displays the orders and the total cost of all the orders.

Grading

Retun the following printouts:

2. Command pattern
//class Stock

public class Stock {
    private String name;
private double price;
    public Product(String name, double price) {
this.name = name;
this.price = price;
}
    public void buy(int quantity){
System.out.println(“BOUGHT: “ + quantity + “x “ + this);
}
    public void sell(int quantity){
System.out.println(“SOLD: “ + quantity + “x “ + this);
}
    public String toString() {
return “Product [name=” + name + “, price=” + price + “]”;
}
}

a. Create two command classes that allows the customer to buy and sold stocks.
b. Write a main method to test it.

Retun the following printouts:

3. Memento pattern

Design a simple calculator that allows to restores the previous additon operation of two numbers.

Retun the following printouts: