Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this is for Java The diagram below shows the layout of the three dens. Theodore\

ID: 647748 • Letter: T

Question

this is for Java

The diagram below shows the layout of the three dens. Theodore's is on the left. It is "U" shaped and is just slightly wider and taller than a single corn ship. Theodore puts chips into the left end of his den and they slide down in single file. Theodore never eats chips, nor does he remove chips from his own den. Note that his den looks suspiciously like a queue.

Simon has been stealing from Theodore's den. He always takes them from the "back door" of Theodore's den. Simon only takes chips from Theodore's den. He never removes chips from his own den. If Theodore's den is empty when Simon is active, Simon does nothing. Sometimes Simon eats the chip, and sometimes he stores it in his own. Simon's den is similar in shape to Theodore's.

Alvin has discovered that Simon is stealing from Theodore. He is blackmailing Simon, and Simon has reluctantly agreed to allow Alvin to take chips from his own rear door. Sometimes Alvin eats a chip If there are chips in Simon's den, Alvin will retrieve the chip and eat it. If Simon's den is empty Alvin will remove a chip from his own den and eat it. He goes hungry if his own den is empty. Sometimes Alvin gets a chip and stores it in his own den. Alvin's den is on the right. Alvin never actually finished his den (typical). Alvin's den looks suspiciously like a stack.

Theodore has discovered what Simon and Alvin are doing. He wants an accounting. He has his list of chips. Your job is to inventory all three dens and list their contents. Then remove each of the found chips from the list. You should end up with a list for each den. You should also have a list of the chips that are missing (Derived by taking the original list and removing any chips that are found in the dens.

The code for the actions is as follows:

Simon attempts to eat a chip. If there is at least one chip in Theodore's den, Simon will steal it and eat it.

The chip and all data on it will be lost. If Theodore's den is empty nothing happens.

You need to implement a linked list (it's fine to steal one from an old program), a queue, and a stack. Represent Theodore's list, Theodore's Den, Simon's Den, and Alvin's Den as instances of the classes. A sample list of input data is shown below. Be sure to test with data that runs the various structures empty.

Assume the dens hold a maximum of 20 chips each. The dens will never overflow (there will never be more than 20 chips in a single den.

Use arrays to implement the list, stack, and queue. Implement the following stack Interface. You should create similar interfaces for Queues and linked lists.

Code Meaning Examples T Theodore gets a chip. This will be followed by the weight of the chip in grams. T 2.38 S E

Simon attempts to eat a chip. If there is at least one chip in Theodore's den, Simon will steal it and eat it.

The chip and all data on it will be lost. If Theodore's den is empty nothing happens.

S S Simon attempts to save a chip in his own den. If there is at least one chip in Theodore's den Simon removes the chip and puts it in his front door. If Theodore's den is empty, Simon does nothing. A E Alvin attempts to eat. Alvin first checks Simon's den. If there is a chip, Alvin removes it and eats it. If there is no chip in Alvin's den then Alvin gets one from his own den if one is available. If none are available, Alvin does not eat. A S Alvin attempts to get a chip from Simon's den. If one is available, Alvin removes it ans stores it in his own den. He does nothing if Simon's den is empty.

Explanation / Answer

import java.awt.*; import java.applet.*; publicclass LineRect extends Applet { publicvoid paint(Graphics g) { g.drawLine(10,10,50,50); g.drawRect(10,60,40,30); g.setColor(Color.blue); g.fillRect(60,10,30,80); g.setColor(Color.green); g.drawRoundRect(10,100,80,50,10,10); g.setColor(Color.yellow); g.fillRoundRect(20,110,60,30,5,5); g.setColor(Color.red); g.drawLine(100,10,230,140); g.drawLine(100,140,230,10); g.drawString("Line Rectangles Demo",65,180); g.drawOval(230,10,200,150); g.setColor(Color.blue); g.fillOval(245,25,100,100); } };