1.3-Object-Georienteerd-Programmeren

Train compartment

View the TrainCompartment class. Your task is to properly apply encapsulation to this class. Make sure that:

For your benefit, we added a class diagram to visualise this exercise.

Make an instance of the TrainCompartment in the Application class and test if your implementation works correctly. Also test the situations that can go wrong.

Examples for inspiration

Preview

Preview

In case the train is empty:

Preview