Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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). Hierarchy of types of parking tickets Briefly explain why the solution in the figure above is not a good one. (7 marks) 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.] (13 marks)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial Accounting

Authors: John Hoggett, John Medlin, Keryn Chalmers, Claire Beattie, Andreas Hellmann, Jodie Maxfield

10th Edition

073036321X, 978-0730363217

Students also viewed these Accounting questions