From the example, the definition of the classes inside of other classes may not be what you want. I think you defined 5 classes, inheritance like this:
Car (inherits from Object)
+-ArrayOne (inherits from Car)
| +-Door (inherits from ArrayOne)(has data Byte handle[3])
|
+-ArrayTwo (inherits from Car)
+-ArrayThree (inherits from Car)
You can see that only Door holds an attribute (handle).
None of the other objects have attributes.
Figure out what attributes, and functions you want every Car to have, and define it there. Only put common code/data there, and specific code in the sub classes.
--------A different interpretation------------
I think this is your intent, but not sure
;class Door
{
public Byte[3] handle
public void Open(){open door here}
public void Close(){close door here}
}
class Car
{
private int m_PassengerCapacity = 4;
private int m_numberPassengers = 0;
abstract public Door[] Doors {get{}set{}}
virtual public bool LoadPeople(int numPeople)
{
if(numPeople < 0)
return UnloadPeople(numPeople);
if(m_PassengerCapacity <= (m_numberOfPassengers+numPeople))
return false;
OpenDoors();
m_numberOfPassengers += numPeople
return true
}
}
class DoesStuff
{
public Car[] ArrayOne = null;
public Car[] ArrayTwo = null;
public Car[] ArrayThree = null;
public void InitArrays(int l1, int l2, int l3)
{
ArrayOne = new Car[l1];
ArrayTwo = new Car[l2];
ArrayThree = new Car[l3];
for(int idx=0;idx < l1; idx++)
ArrayOne[idx] = new Car();
for(int idx=0;idx < l2; idx++)
ArrayTwo[idx] = new Car();
for(int idx=0;idx < l3; idx++)
ArrayThree[idx] = new Car();
}
}
Number of doors is specific to car type.
How many doors to open to load people can depend on car type, num people and existing num passengers.
Door subclasses can handle opening and closing differently for gull wing, hinge or sliding doors.
This won't compile and is not complete, but I hope it gets the idea across.