// this is a minimal translation of the specifications into Java import java.util.*; // ----------------------------------------------------------------------------- // the entry point for the ordering process class Ordering { Vector /* Order */ open = new Vector(); Vector /* Customer */ customers = new Vector(); // -------------------------------------------- Customer lookup(String name) { return null; } Order openOrder(Customer c) { Order o = new Order(c); open.add(o); return o; } // add an order line to o void addLine(Order o, Product p, int q) { o.addLine(p,q); } // compute the value of the order, write to file int closeOrder(Order o) { return o.value(); } } // ----------------------------------------------------------------------------- // representing a customer class Customer { String name; String address; Customer(String name, String address) { this.name = name; this.address = address; } } // ----------------------------------------------------------------------------- // representing an order class Order { Customer c; Vector /* OrderLine */ lines = new Vector(); // -------------------------------------------- Order(Customer c) { this.c = c; } // add a line for p and q to the order void addLine(Product p, int q) { lines.add(new OrderLine(p,q)); } // compute the value of the order int value() { return 10; } } // ----------------------------------------------------------------------------- // representing an orderline class OrderLine { Product p; int q; int value; // -------------------------------------------- OrderLine(Product p, int q) { this.p = p; this.q = q; value = p.price * q; } } // ----------------------------------------------------------------------------- // representing a product class Product { String name; String description; int price; // -------------------------------------------- Product(String name, String description, int price) { this.name = name; this.description = description; this.price = price; } }