A plane class for such an object might look like the following.
Example 1.9 Plane Class
1 public class plane{
2 int Weight;
3 int Speed;
4 int Maneuverability;
5 Location Position; /* The Location type defined elsewhere as an (x, y, z) coordinate */
6
7
plane( int W, int S, int M, Location P ){
8 Weight = W;
9 Speed = S;
10 Maneuverability = M;
11 Position = P;
12 }
13
14
void SetWeight( plane current, int W ){
15 Current.Weight = W;
16 }
17
18
/* Additional Methods for SetSpeed, SetWeight, SetPosition, SetManeuverability,
SetPosition defined here */
19 }
This code is used to initialize a plane object. A calling method specifies each of the
required options that a plane object must have—in this case, a weight, a speed, a maneu-
verability rating, and a position.The SetW ...