Question Details

Answered: - Stacks, Queues, Simulation 1 Overview Over the next few we

Does someone can do this?

I attached the file.

Please check and answer.


Stacks, Queues, Simulation









Over the next few weeks we?ll be doing a project in 3 weekly installments. These start from a doubly


linked list. You?ll need your node to hold different data, but you can use your doubly linked list from


last time as a starting point. There will be several parts to this assignment:


? add methods to make your doubly linked list function as a stack


? add methods to make your link doubly linked list function as a queue


? use it in the context of a larger program









Your client is a stereotypical super-villain?the campy kind like you?d find in the 1960s Adam West


Batman and not the less campy kind you?d find in most contemporary fare. Your client wants to


build a computerized laser-shark tank system. Before investing in the project, he wants you to do


some proof-of-concept simulations.


The whole system will consist of cages for captured heroes, chutes leading into the laser-shark tank,


and a switch that the laser-sharks can trigger if they become hungry. You?re just responsible for the


software part of the project, so you can represent all this with a doubly linked list.


In general, your list will function as a queue (first in, first out). Captured heroes should be enqueued


and dequeued: the first hero in is the first fed to the sharks.


However, your client wants things to be special for his nemesis. When the villain?s nemesis is


captured, she should be placed at the end of the queue. Then the mode will switch from queue


to stack (first in, last out). The end of the queue will become the bottom of the stack. Heroes


captured later will be pushed onto the stack. Heroes from the top of the list will be popped and fed


to the sharks. The villain?s nemesis will have to watch all her friends be fed to the sharks first. This


will give the super-villain time for a good monologue.


Your client assumes that heroes won?t be very coordinated. He?s unaware of the existence of hero


organizations like SHIELD, JLA and OWCA. He figures heroes will find out that their friends are


missing one at a time and head out at their own speed to rescue their friend by themselves as soon


as they notice. This means they will be captured in short order when they reach his lair.



2.1 Assumptions:


? The client thinks 1 hour the longest he can afford to make his monologue. On the one hand,


he has lots of gloating to do. But if he talks too long, his nemesis will probably whip out her


can of shark repellant.


?2013?2016 Cristyn Magnus.


c bna Some rights reserved.






? The shark tank should contain an integer number of laser-sharks. You can?t have half a laser




? Your client has only one nemesis.


? Assume that the sharks start hungry and eat the first hero right away. Also assume that sharks


need to be fed every 8 hours but that they share. So 1 shark would eat every 8 hours, 2 sharks


would eat every 4 hours, etc.


? Also assume that the sharks eat a bit extra if they are starving to make up for lost time. If


there is 1 shark and a hero takes 9 hours to show up, the shark will want to eat in 7 hours.


Either way, they eat every 8 hours if possible.


? You can make your own assumptions about heroes. Come up with a list of heroes. Pick a


nemesis. Decide how long it would take each hero to find out someone is missing and get to


the lair.






Incremental Development



Each week you should hand in a new working part of this project. In previous versions of the course,


this activity was split into several different assignments to encourage incremental development. I?d


still like to encourage that, but I?m trying to leave people more flexibility this time. Below is a


recommended timetable as well as a goals for each week. I?m hoping that by presenting the entire


project at once, people will look at the whole thing and try to make sure they understand how to


do it early on and take the opportunity to go to office hours.


Each week, you must hand in a preliminary, working, documented version of the project. Use good


version control practices: use git1 or make copies of your project folder when you make changes


and give each copy a version number. This will let you continue to move on to new parts of the


program while still having a viable program to hand in.


If you finish the project early, you can just keep handing in the same completed version of the code


& screencast for the remaining assignments. Otherwise, you need to produce tangible progress


towards finishing the project. When you make your screencast demoing your program, be clear


about what you added that is new from last time. If you finish the assignment early and want to


submit a final version, make it clear in the screencast that this is a complete version and submit the


same thing for the rest of the assignments associated with this project. If you change your mind and


want to add more features, you can always submit a new version on a later assignment and explain


the new features in the screencast.





You shouldn?t use a public github repository because that publishes your work to everyone on the web. You can


use a git client to make local, private repositories that don?t leave your computer. If you especially want to use github,


ask them for a free student development pack



?2013?2016 Cristyn Magnus.


c bna Some rights reserved.












week 1: Stack


? Create a class that acts as a doubly linked list node. It should contain all the required data


fields, at least 1 constructor, and a method that prints the hero?s information.


? Create a data file with hero information. Each line should be of the following format:


heroName Nemesis Time


where Nemesis is 1 for the nemesis and 0 for everyone else and Time is in hours.


? Modify your list class to include the following stack methods: push, pop, popAll, printList.


? Create a class that contains a main method for testing/demonstrating.


? In your main method, thoroughly test/demonstrate the methods from your list that you?ve


implemented. You should be able to read your data file and use it to push heroes.


hint: I find it helpful to use the scanner class for this but you can use something else if you


prefer. You can find the scanner class documentation here:



week 2: Queue


? create a class that implements a doubly linked list with the following methods: enqueue,


dequeue, dequeueAll.


? In your main method, thoroughly test/demonstrate the methods that you?ve implemented.


You should be able to read your data file and use it to push heroes.


? Add the ability to switch from queue mode to stack mode. Be able to queue heroes until the


nemesis is enqueued then switch to stack mode until the nemesis is popped then switch back


to queue mode.


hint: You may want to make helper functions that keep track of your state. For instance,


capture might call push/enqueue appropriately when heroes are added and feedToSharks might


pop/dequeue appropriately when heroes are removed.


? In your main method, thoroughly test/demonstrate the methods from your list that you?ve


implemented. You should be able to read your data file and use it to enqueue heroes.


hint: You may want to manually call your capture and feedToSharks methods to test/demonstrate


that your class switches modes properly.



week 3: Simulation ? Complete version due


? Modify your data file so that its first line contains a single integer: the number of sharks


? Modify your code where you read your data file so that the first line is parsed as the number


of sharks and subsequent lines are interpreted as containing heroes.


? Modify your main class so that it keeps track of time since the sharks have been fed & the


number of sharks. When it reads in hero information, it should enqueue until the nemesis


shows up, then push until the nemesis is fed to the sharks, then revert to enqueueing. Every


?2013?2016 Cristyn Magnus.


c bna Some rights reserved.






time a hero arrives, update your time tracker based on that hero?s travel time. Use that to


determine whether someone has been fed to the sharks in the meantime. If so, pop/dequeue


appropriately. When the file is used up, finish pop/dequeueing until there are no more imprisoned heroes.


? Clean up your main method so that it doesn?t have the testing statements from the previous


versions. Construct your input file so that it will demonstrate the following for at least one


number of sharks that you demonstrate:


? enqueueing to the list before the nemesis arrives


? pushing to the list after the nemesis has arrived


? dequeueing from the list if the nemesis has not arrived yet


? popping from the list after the nemesis has arrived.


? enqueueing to the list after the nemesis has been fed to the sharks


? dequeueing from the list after the nemesis has been fed to the sharks.


Hint: You may need to adjust the number of heroes and their time to arrival to make sure all


of these things will happen.


? Once you?ve demonstrated this, take the same list of heroes and figure out the optimum


number of sharks. You can do this by running the simulation with different numbers of sharks


until you find the best number. Remember that the nemesis wants the longest monologue


possible without reaching an hour.


Hint: Since people are coming up with their own test files, there isn?t one right number of


sharks. You?ll need to experiment. A good heuristic is the guessing game heuristic: pick a


number you think is too big and run it with that number to confirm that it is too big. Then


try half that number and see if you have too many or too few. Keep picking the midpoint


between previous guesses until you find the right number.


? In your final screen cast, run your program twice. Once with the number of sharks that


demonstrates full functionality and a second time with what you think is the optimal number


of sharks.









Sketches: Here are some sketches to get you started with planning your program. You may


add additional data, constructors, and methods that you find helpful. You may rename anything


except for the jargon-names: we learn jargon by using it so it?s important to keep enqueue, dequeue,


dequeueAll, push, pop, and popAll. You need to plan your own testing and make your own decisions


about the details of the data representation.



?2013?2016 Cristyn Magnus.


c bna Some rights reserved.












- name : String


- nemesis : int


- travelTime : double


- next : Hero


-prev: Hero





+ enqueue(Hero)


+ dequeue() : Hero


+ dequeueAll()


+ push(Hero)


+ pop() : Hero


+ popAll()


+ printList {query}



+ getName() : String


+ getNemesis() : int


+ getTravelTime() : double


+ getNext() : Hero


+ setNext(nextHero: Hero)


+ getPrev() : Hero


+ setPrev(prevHero: Hero)


+ info {query}





getName ()



Return String name.



getNemesis ()



Return int nemesis.



getTravelTime ()



Return double travelTime.



getNext ()



Return reference to next Hero.



setNext (Hero nextHero) Set next to reference nextHero.


getPrev ()



Return reference to prev Hero.



setPrev (Hero prevHero) Set prev to reference prevHero.


info ()



Print message containing Hero?s name, nemesis status, and travel time.





enqueue (Hero newHero) Add newHero to end of list.





Return the Hero at the front of the list then remove that Hero from the list.






Dequeue Heroes from the list until it is empty.



push (Hero newHero)



Add newHero to the top of the list.






Return the Hero on the top of the list then remove that Hero from the list.






Pop Heroes from the list until it is empty.






Traverse and print the information about all the heroes in the list.



?2013?2016 Cristyn Magnus.


c bna Some rights reserved.






Input: Your input file should look something like this, leaving off the first line if you haven?t


implemented the part that reads in the number of sharks yet:




hero1 0 1.5


hero2 0 3.1


hero3 0 2.6


hero4 1 0.3


hero5 0 1.2


hero6 0 5.8


hero7 0 0.9



Simulation: When your simulation runs, you should print out informative messages. It should


look something like what you see below. You can choose to format it differently if you think it


would be clearer:


0: hero1 has been captured.


0: hero1 has been fed to the sharks.


3.1: hero2 has been captured.


4: hero2 has been fed to the sharks.


5.7: hero3 has been captured.


6: hero4 has been captured.


7.2: hero5 has been captured.


8: hero5 has been fed to the sharks.


12: hero3 has been fed to the sharks.


13: hero6 has been captured.


13.9: hero7 has been captured.


16: hero7 has been fed to the sharks.


20: hero6 has been fed to the sharks.


24: hero3 has been fed to the sharks.


28: hero4 has been fed to the sharks.









In addition to submitting your java code, you will also submit a screencast in which you show your


code and demo it. This lets you show us that your code works on your system. If your code does


not compile, you will receive a 0. You do not need to talk for your screencast; you are just using it


to demonstrate your code.


Use jing to create your screencast. Download jing here:



In your screencast, you should do the following:


?2013?2016 Cristyn Magnus.


c bna Some rights reserved.






? slowly scroll through the file (don?t talk over this part; just scroll slowly enough for someone


to read)


? compile your program to demonstrate that it compiles


? test your program to demonstrate that it works.


? If necessary, expand your test window if there is a lot of output. If there is more output than


fits on screen, scroll slowly through this output as well.


There is a demo screencast you can use as a model here:


When you are done recording your screencast, choose the option to share it at http://screencast.


This will put the url in your clipboard so you can paste it into your blackboard submission.


Do not try to download the screencast and submit that file; just submit the url.











? In the write submission field, provide a link to your screencast at


? Attach your zipped .java file (use .zip, not .rar or some other form of compression)



?2013?2016 Cristyn Magnus.


c bna Some rights reserved.







Solution details:

This question was answered on: Sep 18, 2020

PRICE: $15 (25.37 KB)

Buy this answer for only: $15

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free copy from our tutoring website (Deadline assured. Flexible pricing. TurnItIn Report provided)

Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .

About this Question






Sep 18, 2020





We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

  • As a reference for in-depth understanding of the subject.
  • As a source of ideas / reasoning for your own research (if properly referenced)
  • For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student.


Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.


Order Now