KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > test > WidgetAverages


1 /*
2  * Copyright 2002 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: WidgetAverages.java,v 1.2 2002/10/17 21:01:00 pierreg0 Exp $
9  */

10
11 package com.triactive.jdo.test;
12
13
14 class WidgetAverages extends TestObject
15 {
16     private boolean booleanValue = false;
17     private short avgShortValue = 0;
18     private int avgIntValue = 0;
19
20
21     public WidgetAverages()
22     {
23     }
24
25
26     public boolean getBooleanValue()
27     {
28         return booleanValue;
29     }
30
31
32     public short getAvgShortValue()
33     {
34         return avgShortValue;
35     }
36
37
38     public int getAvgIntValue()
39     {
40         return avgIntValue;
41     }
42
43
44     public void fillRandom()
45     {
46         booleanValue = r.nextBoolean();
47         avgShortValue = (short)(r.nextInt(Short.MAX_VALUE * 2) - Short.MAX_VALUE);
48         avgIntValue = r.nextInt();
49     }
50
51
52     public boolean compareTo(Object JavaDoc obj)
53     {
54         if (obj == this)
55             return true;
56
57         if (!(obj instanceof WidgetAverages))
58             return false;
59
60         WidgetAverages wv = (WidgetAverages)obj;
61
62         return booleanValue == wv.booleanValue
63             && avgShortValue == wv.avgShortValue
64             && avgIntValue == wv.avgIntValue;
65     }
66
67
68     public String JavaDoc toString()
69     {
70         StringBuffer JavaDoc s = new StringBuffer JavaDoc(super.toString());
71
72         s.append(" booleanValue = ").append(booleanValue);
73         s.append('\n');
74         s.append(" avgShortValue = ").append(avgShortValue);
75         s.append('\n');
76         s.append(" avgIntValue = ").append(avgIntValue);
77         s.append('\n');
78
79         return s.toString();
80     }
81 }
82
Popular Tags