|
![]() |
|
||||
|
|
||||||
Due: 9 May.
A marble clock is a clock that indicates the current time in a 24-hour day using marbles to represent portions of the hour and day. There are many different kinds of marble clocks, distinguished by variations in the way the marbles represent portions of the day. Our marble clock consists of five shallow "trays" arranged one above the other. The bottom tray (the fifth tray) serves as a marble "reservoir." Every minute, a winding mechanism picks up one marble from the bottom tray, carries it to the top of the clock and drops it into the top tray of the clock. As a tray fills up, marbles fall through to lower level trays, as described below. The current state of the marbles in the upper four trays tells the current time.
Each marble in the top tray (first tray) represents a single minute. This first tray has room for four marbles. These marbles all enter from the same end and roll down to the other end of the tray. When the first tray is full, the next marble drops to the second tray (the second tray represents 5 minute intervals) and, in the process, trips a latch that tilts the top tray causing the marbles there to exit the same end that they entered and return to the end of the line in the reservoir (bottom) tray. The second tray holds a maximum of two marbles, and when a third marble arrives, it drops to the next tray (representing 15 minute intervals). Then, the second tray is emptied in a manner analogous to the first. Finally, the third (15-minute) tray can hold three marbles and a fourth marble drops into the hours tray (fourth tray), causing the 15 minute tray to be emptied back into the reservoir. The hours tray holds 11 marbles, when a twelfth marble arrives, it trips the tray which empties into the reservoir. The tripping marble then also drops into the reservoir, completing the cycle. Thus, a complete cycle is 12 hours.
Write a program in the programming language of your team project. The program must use stacks and queues that simulate the behavior of the marble clock. Integers may be used to represent the marbles (that is, marbles are numbered 1, 2, 3, 4, 5, ...). The initial number of marbles used to fill the reservoir is obtained as user input. Experiment with the simulation to determine the number of 12-hour cycles the clock goes through before the marbles in the reservoir are back in their original order (relative to the number of input marbles used to fill the reservoir).
Notes: You may use an implementation (i.e., arrays or linked lists) of stacks and queues of your own choosing. Note, however, that you may not violate the ADT for these data structures. You should implement standard stack and queue operations and only operate on the trays using these. A size() operation that returns the number of elements is OK. An operation that "indexes" into the structure or traverses the structure to determine if they are in order is not permitted.
Optional: If your language supports graphics, you may wish to simulate the operation of your clock with graphics.
Reminder: As part of your language presentation at the end of the semester, you are expected to illustrate your common program and how it works in your language.
Three-of-a-crime is a simple logic game for up to 3 players. There are 7 different criminals. The computer randomly chooses three of these (the "perpetrators"), but doesn't tell the players which are chosen. The computer then puts down three random criminals. 0, 1, or 2 of these may be the actual perpetrators. The computer also tells the player how many (but not which) of the three criminals are perpetrators. The players may either guess which three criminals are the actual perpetrators or they may pass. If a player guesses wrong, she is out of the game and the other players continue. If no player chooses to guess, the computer puts down another three randomly chosen criminals (0, 1, or 2 of which may be actual perpetrators) and tells the players how many (but not which) of these are actual perpetrators. Players can again use logic to deduce the three actual criminals and may guess. Play continues until some player guesses correctly or until all players have guessed incorrectly.
An example play:
Your program should be visual if possible with your language. Only if your language does not support GUI interactions may you use a text based interface.
This program will translate from Chineese to English. You will receive two files, a file that contains a Chineese text (written in latin characters) and a glossary. The glossary will contain Chineese words and their English counterpart. Your program must process the Chineese text file and translate it word by word by looking up each word in the glossary to find the English equivelant.
The translation must be interleaved. The original Chineese text must be displayed on one line with the English translation displayed on the line underneath it. You must write the translation to a file. The words must be spaced so that there is no overlapping, i.e., if the Chineese word is longer than the English equivelant, then it must be filled out with blanks and vice versa.
The glossary will have the following format:
aenvih,because aeq,huh aeu,get,want,use,take aeuj,purple aeuq,stew aeuqheiq,get angry baenxlai aek,so much,so very, thanks
Here's a glossary that you can use.
|
|
|
Last updated on
25 Jan 2008
by
John
Barr
|