01: package samples.bidbuy;
02:
03: /**
04: * Big/PurchaseOrder Service
05: */
06: public class BidService {
07:
08: static int nextReceiptNumber = 9000;
09:
10: /**
11: * Request a quote for a given quantity of a specified product
12: * @param productName name of product
13: * @param quantity number desired
14: * @return Total amount in US$ for complete purchase
15: */
16: public double RequestForQuote(String productName, int quantity) {
17: if (quantity < 100) {
18: return 1.0 * quantity;
19: }
20: if (quantity < 1000) {
21: return 0.8 * quantity;
22: } else {
23: return 0.7 * quantity;
24: }
25:
26: }
27:
28: /**
29: * Purchase a given quantity of a specified product
30: * @param productName name of product
31: * @param quantity number desired
32: * @param price desired price (!!!)
33: * @param customerId who you are
34: * @param shipTo where you want the goods to go
35: * @param date where you want the goods to go
36: * @return Receipt
37: */
38: public String SimpleBuy(String productName, String address,
39: int quantity) {
40: return Integer.toString(nextReceiptNumber++) + "\n" + quantity
41: + " " + productName;
42: }
43:
44: /**
45: * Process a purchase order.
46: * @return Receipt
47: */
48: public String Buy(PurchaseOrder PO) {
49: String receipt = Integer.toString(nextReceiptNumber++);
50:
51: for (int i = 0; i < PO.getItems().length; i++) {
52: LineItem item = PO.getItems()[i];
53: receipt += "\n " + item.getQuantity() + " "
54: + item.getName();
55: }
56:
57: return receipt;
58: }
59:
60: /**
61: * Let the world know that we are still alive...
62: */
63: public void Ping() {
64: }
65:
66: }
|