comp.lang.ada
 help / color / mirror / Atom feed
From: gattamaneni abhiram <abhiram.gattamaneni@gmail.com>
Subject: Marble Clock
Date: Mon, 1 Apr 2013 17:09:13 -0700 (PDT)
Date: 2013-04-01T17:09:13-07:00	[thread overview]
Message-ID: <7075541f-01b7-4cd4-997f-b0b8048f067d@googlegroups.com> (raw)

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.

Above behaviour of the clock is to be implemented using stacks and queues.
The initial number of marbles to be taken is the user input.

Can anyone please help me with the logic in the program?



             reply	other threads:[~2013-04-02  0:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-02  0:09 gattamaneni abhiram [this message]
2013-04-02 12:02 ` Marble Clock John B. Matthews
2013-04-02 19:46   ` gattamaneni abhiram
2013-04-02 19:54     ` Eryndlia Mavourneen
2013-04-03  9:14       ` Simon Wright
2013-04-03 12:45         ` Eryndlia Mavourneen
2013-04-03 16:53         ` Simon Wright
2013-04-12 22:28         ` gattamaneni abhiram
2013-04-13  5:51           ` Simon Wright
2013-04-13 19:04           ` Dennis Lee Bieber
2013-04-03 11:52     ` John B. Matthews
2013-04-03  7:44 ` Mike H
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox