Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have been trying to implement the State Pattern into my Library UML and I am not sure if I am on the right track.

I have been trying to implement the State Pattern into my Library UML and I am not sure if I am on the right track. I have 6 states for showing the availability of an Item to help the Librarian find them. For context there are 3 guidelines which I have already implemented, however I am not 100% confident if I did it right:

1. Only SHELF state can loan and display.

2. DISPLAY, OUT, REPAIR states can RETURN but each goes to a different state

3. Return shelves

(The 6 states are SHELF, DISPLAY, OUT, RETURN, REPAIR, DISCARD)

First, here is a drawing of how I think the State flow will be based on the guidelines above (I apologize I couldn't flip it around):

image text in transcribed

Here is my State UML Diagram. My "Context" Class is the Item Class and I created an instance variable to hold its current State.

I am unsure about which methods to add to each State. I think each state needs +getItem() and certain States, such as "OutState" would need +getOnLoanIndicator() to update when the Item has been borrowed. I am just not sure about the State classes themselves, I feel as though I have implemented them incorrectly. Any feedback and advice is much much appreciated as I have been stuck on this for a while! Thank you!

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

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

25 Vba Macros For Data Analysis In Microsoft Excel

Authors: Klemens Nguyen

1st Edition

B0CNSXYMTC, 979-8868455629

More Books

Students also viewed these Databases questions

Question

What is computer neworking ?

Answered: 1 week ago