Quote:
Originally Posted by mikelowry
Ok, thank you.
But what about the constructors for the Joystick and RobotDrive? Why does it make a difference wether or not they are inside the class. It compiles fine either way.
|
In general, it is best practice to encapsulate the state of a class (i.e. the joysticks and RobotDrive) within the class. This allows you to create multiple instances of the class safely.
It also makes it easier to debug and modify since if they are contained within the class no other objects have direct access to them.
In this case it
shouldn't matter since you should only ever have a single instance of the robot class. However it is still best practice.