Answered step by step
Verified Expert Solution
Question
1 Approved Answer
SYSTEMS ANALYSIS AND DESIGN In the figure below you see a fragment of class diagram that represents parking tickets. Tickets have a state (mostly depending
SYSTEMS ANALYSIS AND DESIGN
In the figure below you see a fragment of class diagram that represents parking tickets. Tickets have a state (mostly depending on how long they have been waiting, but the details are not relevant here) represented by the hierarchy in the figure; the operation calculateCharge(), which is abstract in the parent class, is overridden in the child classes because its behaviour depends on the state of the ticket (and obviously on the specific child class).
- Briefly explain why the solution in the figure above is not a good one.
- Draw a (fragment of) class diagram that represents parking tickets and their states by means of the State pattern, with the overriding of calculateCharge() according to the state. [Note: you are not required to detail the classes; names, association(s), inheritance and the single operation calculateCharge() will be sufficient.]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started