SE450: Putting Patterns to Work [57/72] |
file:horstmann/ch05_invoice/LineItem.java [source] [doc-public] [doc-private]
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
package horstmann.ch05_invoice; /** A line item in an invoice. */ public interface LineItem { /** Gets the price of this line item. @return the price */ double getPrice(); /** Gets the description of this line item. @return the description */ String toString(); }
file:horstmann/ch05_invoice/Product.java [source] [doc-public] [doc-private]
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
package horstmann.ch05_invoice; /** A product with a price and description. */ public class Product implements LineItem { /** Constructs a product. @param description the description @param price the price */ public Product(String description, double price) { this.description = description; this.price = price; } public double getPrice() { return price; } public String toString() { return description; } private String description; private double price; }