| 27 | === Checksum |
| 28 | A checksum is a small integer that is transmitted at the end of a message. The value depends on the message sent. The checksum is used to determine the integrity of the message as it's sent over the wire. For more information about how checksums are used, see [https://youtu.be/b4b8ktEV4Bg this video] or [https://www.google.com/search?q=what+is+a+checksum&oq=what+is+a+checksum&aqs=chrome..69i57j0l5.3006j0j7&sourceid=chrome&es_sm=91&ie=UTF-8 this]. |
| 29 | |
| 30 | For this problem, you will implement a simple hash/checksum algorithm. |
| 31 | |
| 32 | Write a static method that takes in a string and returns it's {{{short}}} typed checksum. Calculate the checksum using the following steps: |
| 33 | 1. For each character, convert the {{{String}}} to a {{{char}}}. |
| 34 | 2. For each {{{char}}}, raise it to the power of its index. (For example, the 7th {{{char}}} will be raised to the 6th power.) |
| 35 | 3. Sum the powers. |
| 36 | 4. Modulus divide the sum to make it fit in a {{{short}}} data type. |
| 37 | |
| 62 | === !IceCreamParlor |
| 63 | {{{ |
| 64 | #!div style="color:white" |
| 65 | This problem involves a simulation, which is provided in the starter code for your convenience. |
| 66 | }}} |
| 67 | {{{ |
| 68 | #!div style="color:red" |
| 69 | This problem also involves writing several classes(part a) using multithreading (part b). |
| 70 | }}} |
| 71 | |
| 72 | '''Rules of the Simulation'''[[BR]] |
| 73 | 1. There exists an ice cream shop in the distant land of Starvedlandia which employs 6 robot employees, all identical except for one who is the manager. |
| 74 | 2. The simulation will run for one "day" where some human customers will come in and purchase some amount of ice cream (# of scoops) of a set of types (chocolate, vanilla, strawberry, cookies and cream, mint). |
| 75 | 3. All the ice cream is stored in a freezer which can only be accessed by one employee at a time. |
| 76 | a. Because the robots are all paranoid that the human slaves will rebel and become sentient, they keep all the ice cream locked in the freezer with the only key in the hands of the manager. |
| 77 | b. To open the freezer, an employee goes to the manager, requests the key, gets the ice cream from the freezer, and then, after relocking the freezer, returns the key to the manager. |
| 78 | c. The manager can only see one person at a time. |
| 79 | d. ''Special note: When implementing the multithreading portion of this, be aware of the deadlock possibility here, depending on your implementation.'' |
| 80 | 4. There are two cash registers available to the employees (5 out front) which they need to use to process the transaction. Each cash register can process one transaction at a time; the other employees will have to wait. |
| 81 | |
| 82 | Assume an infinite amount of ice cream is stored in the freezer. |
| 83 | |
| 84 | |
| 85 | To recap and clarify, a customer comes in wanting to buy ice cream and approaches an employee (not the manager); the employee must learn how much and what type of ice cream the customer wants. To get the ice cream, they need to go to the manager, get the key, go to the freezer, get the ice cream, and return the key to the manager. Then the employee needs to find an open cash register to finish the transaction. |
| 86 | |
| 87 | '''Part 1: Implement Classes'''[[BR]] |
| 88 | The following classes will be essential to be implemented. You may decide other classes are necessary. It is recommended to build from the starter code, and not modify it. |
| 89 | '''public class Manager''' |
| 90 | |
| 91 | === !AlternativeVote |
| 92 | [[Image(http://sightline.wpengine.netdna-cdn.com/wp-content/uploads/2015/06/Foodtown-Legislature-square.jpeg, 40%, right)]] The U.S. uses the voting system of First Past the Post (or winner-takes-all election), which ''can'' cause a candidate who has won less than the majority to win all the votes, resulting in disproportionate representation. |
| 93 | |
| 94 | {{{ |
| 95 | #!div style="color:blue" |
| 96 | There is a graphical user interface (GUI) built to run alongside your code for this prompt. |
| 97 | }}} |
| 98 | |
| 99 | ---------------------------------------------------------- |
| 100 | |