Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Remember that Totally Not Pokemon game from near the beginning of the semester? You decide the next step is to make a multiplayer, MMO-style version

Remember that Totally Not Pokemon game from near the beginning of the semester? You decide the next step is to make a multiplayer, MMO-style version of it. Players will log into a central server, which will maintain a queue of login requests so that not too many people are playing at the same time. Unfortunately, the intern you hire to help you write the MMO code never passed his data structures class. (This makes you wonder why you hired him in the first place, but thats a discussion for another time!) He insists that the login queue should store the queue elements in a linked list and should always fix the front of the queue at the tail of the list, because thats easier. All your attempts at explaining why this is a Horrible Idea are met with much resistance. And due to strict labor laws, you cant just fire the intern without good reason. So you decide the best course of action is to implement the interns plan, deploy it on your live server, watch your game subscriptions take a precipitous dive, blame the intern for it, use that as a reason to let him go, and then sue him to recover your lost revenue. Because MURICA. a. (10 pts) Write a NaughtyLLQueue class. Your class should implement a queue using a single linked list. However, it should use the tail of the list as the front of the queue, meaning that when a dequeue is performed, a traversal from the head node is required. Implement all four methods from the Queue interface (isEmpty, peek, enqueue, and dequeue) for this class. Calling dequeue or peek on an empty queue should return null, as our code did during lecture. b. (5 pts) Write a client program that simulates the logging in of 100,000 players by using your bad queue implementation as well as the good implementation that we wrote in class. Measure the time needed to enqueue all 100,000 players, and then the time needed to remove them all from the queue. Remember that you can use the built-in method System.currentTimeMillis() to get the current system time in milliseconds. Use this as a stopwatch call currentTimeMillis once to get the starting time, execute the code you want to time, and then call currentTimeMillis again to get the ending time. The elapsed time is simply the difference between the start and end times.

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions