- Design proper abstraction (interfaces)
- Apply inheritance
- Fix encapsulation
- Use polymorphism to represent every type of car, using a single pointer
- Fix a diamond problem
- Fix potential memory leaks
- Think about the way of keeping engines in cars. Should they be kept by a value, reference or a pointer (what kind of pointer)?
- Is this code testable?
You can work in groups or individually. Please fork the repo and submit a Pull Request after you have finished.
- Create
InvalidGear
exception. It should be thrown when someone tries eg. change a gear from 5 to R. It should inherit from one of STL exceptions - Fix interfaces to be easy to use correctly and hard to use incorrectly (like
accelerate(-999)
) - (Optional) Write proper unit tests to this code.
- Read one of below articles. It will be useful for the next lesson.