File: BidService.java

package info (click to toggle)
axis 1.4-29
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 52,100 kB
  • sloc: java: 129,124; xml: 10,602; jsp: 983; sh: 84; cs: 36; makefile: 18
file content (63 lines) | stat: -rw-r--r-- 1,665 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package samples.bidbuy;

/**
 * Big/PurchaseOrder Service
 */
public class BidService {

    static int nextReceiptNumber = 9000;

    /**
     * Request a quote for a given quantity of a specified product
     * @param productName name of product
     * @param quantity number desired
     * @return Total amount in US$ for complete purchase
     */
    public double RequestForQuote(String productName, int quantity) {
        if (quantity < 100) {
           return 1.0 * quantity;
        } if (quantity < 1000) {
           return 0.8 * quantity;
        } else {
           return 0.7 * quantity;
        }
 
    }

    /**
     * Purchase a given quantity of a specified product
     * @param productName name of product
     * @param quantity number desired
     * @param price desired price (!!!)
     * @param customerId who you are
     * @param shipTo where you want the goods to go
     * @param date where you want the goods to go
     * @return Receipt
     */
    public String SimpleBuy(String productName, String address, int quantity) {
        return Integer.toString(nextReceiptNumber++) + "\n" +
            quantity + " " + productName;
    }

    /**
     * Process a purchase order.
     * @return Receipt
     */
    public String Buy(PurchaseOrder PO) {
        String receipt = Integer.toString(nextReceiptNumber++);

        for (int i=0; i<PO.getItems().length; i++) {
            LineItem item = PO.getItems()[i];
            receipt += "\n  " + item.getQuantity() + " " + item.getName();
        }

        return receipt;
    }

    /**
     * Let the world know that we are still alive...
     */
    public void Ping() {
    }

}