GOFPatterns
Technology
Search
SiteMap
eWebProgrammer
J2EEOnline
Design Patterns
Defining Patterns
Singleton Patterns
Creational Patterns
Structural Design Patterns
Behavioral Design Patterns
Design Pattern SW Design
The Factory Method Pattern - Exercise
Objective:
Write an abstract Vehicle class. In this exercise, you willl write an abstract Vehicle class that has the structure shown in this diagram:
When working with C++, overload the
<<
operator instead of using a
toString()
method.
The
accelerate()
and
decelerate()
methods should be used to change the speed. However, they are subject to the constraints that the speed is always greater than or equal to zero and less than or equal to
maxSpeed
. Attempts to increase speed above
maxSpeed
or decrease it below 0 should simply pin the speed to the boundaries.
Note that this class is quite general and can actually describe pedestrians as well.
In the text area below, type or paste your answer.
Click the
Submit
button to submit the factory method exercise.