KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > grid > gridOperationsImpl


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