Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

As an intern at Amazon, you have been assigned a task toimplement the sign-in pages in the Amazon Dummy Website. There arethree sign-in pages, each

As an intern at Amazon, you have been assigned a task toimplement the sign-in pages in the Amazon Dummy Website. There arethree sign-in pages, each with its own API: Register Login LogoutFunction Registers a new user with the username and passwordusername logs out of the website Verifies the username andpassword, then grants or denies access API Request register loginlogout Returns • If the registration was successful, RegisteredSuccessfully • If the user already exists, Username already exists• If the login was successful, Logged In Successfully • If thelogin was unsuccessful Login Unsuccessful • If the logout wassuccessful, Logged Out Successfully • If the given username wasn'tlogged in Logout Unsuccessful Given a log of API requests, returnthe list of returns from the mock website. Given a log of APIrequests, return the list of returns from the mock website. Notes:• Initially, there are no users registered. • If a user is alreadylogged in and makes a login request, the new request isunsuccessful. The origi login remains active. • Each log is an APIrequest and is in one of the three allowed formats. • The order ofexecution of each request is the same as the order of input. • Theusernames and passwords are case-sensitive. Example The websitereceives the following API requests in order: . • register user 05qwerty • A new user with the username "user05" is registered to thewebsite with the password "qwerty o The return value isRegisteredSuccessfully login useros qwerty o There is a user with thatusername. The password matches that user's password. The user isnot already logged in. • The login is successful and the returnvalue is Logged In Successfully • logout user 5 The user withusername "user 05" is currently logged in. • The logout issuccessful and the return value is Logged Out Successfully Returnthe array ("Registered Successfully", "Logged In Successfully","Logged Out Successfully"). Function Description Complete thefunction implementAPI in the editor below. implementAPI has thefollowing parameter: string logs[n]: each of the API requestsReturns string(n): an array of strings where th string is thereturn value of the ith API request Constraints . isnsios . 15username , I password | s10 (where Is is the length of strings) •username and password are alphanumeric strings, ranges [0-9, a-z,A-Z] Input Format For Custom Testing The first line contains aninteger, n, the number of elements in logs. Each line of the nsubsequent lines (where 0 si)

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

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

More Books

Students also viewed these Programming questions

Question

Define a traverse in Surveying?

Answered: 1 week ago