1   package simworldobjects;
2   
3   import interfaces.*;
4   
5   /**
6   * Abstract class for SimObjects, provides a base implementation of 
7   * the SimObject interface which more complex objects can extend. (e.g
8   * SimRCX and SimLight).
9   *
10  * @see interfaces.SimObject
11  * 
12  * @author Graham Ritchie
13  */
14  public abstract class BasicSimObject implements SimObject
15  {
16      // position variables
17      private double desiredVelocity;
18      private double actualVelocity;
19      private double xCoord;
20      private double yCoord;      
21      private double zCoord;
22      
23      // bearing variables
24      private double desiredBearingVelocityXZ; // +x: clockwise, -x: anticlockwise
25      private double desiredBearingVelocityXY; // +x: clockwise, -x: anticlockwise
26      private double actualBearingVelocityXZ;
27      private double actualBearingVelocityXY;
28      private double actualBearingXZ;
29      private double actualBearingXY;
30      
31      // physical properties (must be set in constructor)
32      private double height;  // y
33      private double width;   // z
34      private double length;  // x
35      
36      // type property (must be set in constructor)
37      private String type; // permitted: light, robot, wall, sensor, floor
38      
39      public BasicSimObject(double height, double width, double length, String type, double x, double y, double z, double bearingXY, double bearingXZ)
40      {
41          // initialise all variables
42          this.height=height;
43          this.width=width;
44          this.length=length;
45          this.type=type;
46          this.xCoord=x;
47          this.yCoord=y;
48          this.zCoord=z;
49          this.actualBearingXZ=bearingXZ;
50          this.actualBearingXY=bearingXY;
51          
52          this.desiredVelocity=0;
53          this.actualVelocity=0;
54          
55          this.desiredBearingVelocityXZ=0;
56          this.desiredBearingVelocityXY=0;
57          this.actualBearingVelocityXZ=0;
58          this.actualBearingVelocityXY=0;
59      }
60      
61      // get and set methods for all variables
62  
63      public void setDesiredVelocity(double v)
64      {
65          this.desiredVelocity=v;
66      }
67      
68      public void setActualVelocity(double v)
69      {
70          this.actualVelocity=v;
71      }
72      
73      public void setXCoord(double x)
74      {
75          this.xCoord=x;
76      }
77      
78      public void setYCoord(double y)
79      {
80          this.yCoord=y;
81      }
82      
83      public void setZCoord(double z)
84      {
85          this.zCoord=z;
86      }
87      
88      public double getDesiredVelocity()
89      {
90          return this.desiredVelocity;
91      }
92      
93      public double getActualVelocity()
94      {
95          return this.actualVelocity;
96      }
97      
98      public double getXCoord()
99      {
100         return this.xCoord;
101     }
102     
103     public double getYCoord()
104     {
105         return this.yCoord;
106     }
107     
108     public double getZCoord()
109     {
110         return this.zCoord;
111     }
112     
113     public void setDesiredBearingVelocityXZ(double v)
114     {
115         this.desiredBearingVelocityXZ=v;
116     }
117     
118     public void setDesiredBearingVelocityXY(double v)
119     {
120         this.desiredBearingVelocityXY=v;
121     }
122     
123     public void setActualBearingVelocityXZ(double b)
124     {
125         this.actualBearingVelocityXZ=b;
126     }
127     
128     public void setActualBearingVelocityXY(double b)
129     {
130         this.actualBearingVelocityXY=b;
131     }
132     
133     public void setActualBearingXZ(double b)
134     {
135         this.actualBearingXZ=b;
136     }
137     
138     public void setActualBearingXY(double b)
139     {
140         this.actualBearingXY=b;
141     }
142 
143     public double getDesiredBearingVelocityXZ()
144     {
145         return this.desiredBearingVelocityXZ;
146     }
147     
148     public double getDesiredBearingVelocityXY()
149     {
150         return this.desiredBearingVelocityXY;
151     }   
152     
153     public double getActualBearingVelocityXZ()
154     {
155         return this.actualBearingVelocityXZ;
156     }
157     
158     public double getActualBearingVelocityXY()
159     {
160         return this.actualBearingVelocityXY;
161     }
162     
163     public double getActualBearingXZ()
164     {
165         return this.actualBearingXZ;
166     }
167     
168     public double getActualBearingXY()
169     {
170         return this.actualBearingXY;
171     }
172     
173     public double getHeight()
174     {
175         return this.height;
176     }
177     
178     public double getWidth()
179     {
180         return this.width;
181     }
182     
183     public double getLength()
184     {
185         return this.length;
186     }
187 
188     public String getType()
189     {
190         return this.type;
191     }
192 }
193