01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: Weight.java,v 1.9.2.2 2008/01/07 15:14:00 cwl Exp $
07: */
08:
09: package collections.ship.basic;
10:
11: import java.io.Serializable;
12:
13: /**
14: * Weight represents a weight amount and unit of measure.
15: *
16: * <p> In this sample, Weight is embedded in part data values which are stored
17: * as Serial serialized objects; therefore Weight must be Serializable. </p>
18: *
19: * @author Mark Hayes
20: */
21: public class Weight implements Serializable {
22:
23: public final static String GRAMS = "grams";
24: public final static String OUNCES = "ounces";
25:
26: private double amount;
27: private String units;
28:
29: public Weight(double amount, String units) {
30:
31: this .amount = amount;
32: this .units = units;
33: }
34:
35: public final double getAmount() {
36:
37: return amount;
38: }
39:
40: public final String getUnits() {
41:
42: return units;
43: }
44:
45: public String toString() {
46:
47: return "[" + amount + ' ' + units + ']';
48: }
49: }
|