01: /*
02: * MyGWT Widget Library
03: * Copyright(c) 2007, MyGWT.
04: * licensing@mygwt.net
05: *
06: * http://mygwt.net/license
07: */
08: package net.mygwt.samples.resources.client;
09:
10: import java.util.Date;
11:
12: import net.mygwt.ui.client.data.Model;
13:
14: public class Stock extends Model {
15:
16: public Stock() {
17: }
18:
19: public Stock(String name, String symbol, double open, double last) {
20: set("name", name);
21: set("symbox", symbol);
22: set("open", new Double(open));
23: set("last", new Double(last));
24: set("date", new Date());
25: }
26:
27: public Date getLastTrans() {
28: return (Date) get("date");
29: }
30:
31: public String getName() {
32: return getAsString("name");
33: }
34:
35: public String getSymbol() {
36: return getAsString("symbox");
37: }
38:
39: public double getOpen() {
40: Double open = (Double) get("open");
41: return open.doubleValue();
42: }
43:
44: public double getLast() {
45: Double open = (Double) get("last");
46: return open.doubleValue();
47: }
48:
49: public double getChange() {
50: return getLast() - getOpen();
51: }
52:
53: public double getPercentChange() {
54: return getChange() / getOpen();
55: }
56:
57: public String toString() {
58: return getName();
59: }
60:
61: }
|