Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Plz write in PYTHON I was able to start by storing the owner and keys but am struggling after that more info is needed? Only

Plz write in PYTHON

I was able to start by storing the owner and keys but am struggling after that

image text in transcribedimage text in transcribedimage text in transcribed

more info is needed?
Only users with an authorized key can enter the house. To enter the house, the user must first put their key in the lock, then turn the lock, then enter the house, only if the key is valid. A house can be rekeyed with new keys only by the owner, and only if the owner is inside the house. Firefighters can enter with the secret key (literal string) FIREFIGHTER_SECRET_KEY. The lock will always be accessed in the following way: insert key, turn the lock, then enter the house it is not guaranteed that it is the same user, however). Other commands can be issued in between insert, turn, and enter, however they do not affect the lock state. Testing if a key is valid is done when the lock is turned. INSERT KEY inserts key key into the door. Response should be: KEY INSERTED BY TURN KEY turns the key in the door. Possible responses are: SUCCESS TURNS KEY or FAILURE UNABLE TO TURN KEY ENTER HOUSE enters the house. Possible responses are: ACCESS DENIED or ACCESS ALLOWED. WHO'S INSIDE? Who is currently inside the house? Response must be a comma-separated list of user names, ordered by access time (earlier access first): , , ... or NOBODY HOME if there are no users in the house. CHANGE LOCKS ... wishes to rekey the house with new given keys , , ..., . Possible responses are: ACCESS DENIED or OK LEAVE HOUSE leaves the house. Possible responses are: OK or NOT HERE If any events are received that are not according to this specification, the response must be: ERROR. Example Running the program as follows: ./secure_house selina foobar Given the input: INSERT KEY adam key TURN KEY adam ENTER HOUSE adam INSERT KEY pat foobar TURN KEY pat ENTER HOUSE pat WHO'S INSIDE? The program will produce the following output: KEY key INSERTED BY adam FAILURE adam UNABLE TO TURN KEY key ACCESS DENIED KEY foobar INSERTED BY pat SUCCESS pat TURNS KEY foobar ACCESS ALLOWED pat Only users with an authorized key can enter the house. To enter the house, the user must first put their key in the lock, then turn the lock, then enter the house, only if the key is valid. A house can be rekeyed with new keys only by the owner, and only if the owner is inside the house. Firefighters can enter with the secret key (literal string) FIREFIGHTER_SECRET_KEY. The lock will always be accessed in the following way: insert key, turn the lock, then enter the house it is not guaranteed that it is the same user, however). Other commands can be issued in between insert, turn, and enter, however they do not affect the lock state. Testing if a key is valid is done when the lock is turned. INSERT KEY inserts key key into the door. Response should be: KEY INSERTED BY TURN KEY turns the key in the door. Possible responses are: SUCCESS TURNS KEY or FAILURE UNABLE TO TURN KEY ENTER HOUSE enters the house. Possible responses are: ACCESS DENIED or ACCESS ALLOWED. WHO'S INSIDE? Who is currently inside the house? Response must be a comma-separated list of user names, ordered by access time (earlier access first): , , ... or NOBODY HOME if there are no users in the house. CHANGE LOCKS ... wishes to rekey the house with new given keys , , ..., . Possible responses are: ACCESS DENIED or OK LEAVE HOUSE leaves the house. Possible responses are: OK or NOT HERE If any events are received that are not according to this specification, the response must be: ERROR. Example Running the program as follows: ./secure_house selina foobar Given the input: INSERT KEY adam key TURN KEY adam ENTER HOUSE adam INSERT KEY pat foobar TURN KEY pat ENTER HOUSE pat WHO'S INSIDE? The program will produce the following output: KEY key INSERTED BY adam FAILURE adam UNABLE TO TURN KEY key ACCESS DENIED KEY foobar INSERTED BY pat SUCCESS pat TURNS KEY foobar ACCESS ALLOWED pat

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

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

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions