KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > grid > gridImpl


1 package demo.grid;
2
3 /**
4  * A very simple implementation of a 2-D grid
5  */

6
7 import demo.grid.MyServerPackage.MyException;
8
9
10 public class gridImpl
11     extends MyServerPOA
12 {
13     protected short height = 31;
14     protected short width = 14;
15     protected java.math.BigDecimal JavaDoc[][] mygrid;
16  
17     public gridImpl()
18     {
19         mygrid = new java.math.BigDecimal JavaDoc[height][width];
20         for( short h = 0; h < height; h++ )
21         {
22             for( short w = 0; w < width; w++ )
23             {
24                 mygrid[h][w] = new java.math.BigDecimal JavaDoc("0.21");
25             }
26         }
27     }
28
29     public java.math.BigDecimal JavaDoc get(short n, short m)
30     {
31         if( ( n <= height ) && ( m <= width ) )
32             return mygrid[n][m];
33         else
34             return new java.math.BigDecimal JavaDoc("0.01");
35     }
36
37     public short height()
38     {
39         return height;
40     }
41
42     public void set(short n, short m, java.math.BigDecimal JavaDoc value)
43     {
44         if( ( n <= height ) && ( m <= width ) )
45             mygrid[n][m] = value;
46     }
47
48     public short width()
49     {
50         return width;
51     }
52
53     public short opWithException()
54         throws demo.grid.MyServerPackage.MyException
55     {
56         throw new demo.grid.MyServerPackage.MyException("This is only a test exception, no harm done :-)");
57     }
58
59
60
61 }
62
63
64
Popular Tags