alice-teacher s Digest, Vol 73, Issue 8

robert durtschi robert.durtschi at gcsu.edu
Wed Oct 26 06:21:22 EDT 2016


It may help if you visualize how a clock works. For the run method:


   The minutes counts from zero to 60 (increment clock.minutes by 1)

   When minutes reach 60 (if clock.minutes >= 60)

       minutes are reset to zero (clock.minutes set value to 0)

       increment clock.hours by 1

       when hours reach 12 (if clock.hours >=12)

           hours are reset to zero (clock.hours set value to zero)


That's the model of a clock.  All you need to do for the view part is add a

       "clock.minuteHand roll left 1/60" after the increment clock.minutes by 1

and a "clock.hourHand roll left 1/12" after the increment clock.hours by 1


finally add a "wait (waitTime seconds)" at the bottom of the clock.run edit window

where the waitTime variable is set to 60 for normal speed, 1 for 60 times normal speed, and 1/60 for 3600 times normal speed


All three variables should be created in the clock properties tab.

otherwise seconds is reset to zero every time clock.run is invoked.

(How do I know this? "you learn from mistakes")


The best way to have the clock "run" continuously is to

"create new event" "when the world starts" in the Alice 2 event area.

right-click change to "while the world is running"

then drag the clock "run" method onto the "during" part


The other methods and functions you mentioned would interact with the hours, minutes, and waitTime variables as described in the requirements


I can make suggestions about them if you need help. Just email me at

robert.durtschi at gcsu.edu


Best

Bob Durtschi

________________________________
Alice Teachers List - Carnegie Mellon University<https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers>
lists.andrew.cmu.edu
Alice is an engaging, introductory programming environment for the creation of animations and games using 3D models. Alice features a drag-and-drop interface that ...


Message: 1
Date: Mon, 24 Oct 2016 15:50:08 -0400
From: "Nichols, Denise" <dnichols at yorkcatholic.org>
To: alice-teachers at lists.andrew.cmu.edu
Subject: alice-teacher Help Needed: Alice 2.4 Clock Project

I am using the *Alice in Action* textbook written by Joel Adams.  In
Chapter 4 Flow Control, there is a programming project that my class and I
just cannot figure out.  I have the solution file, but we are not sure how
it was coded.  Does anyone have any suggestions?

Here is the directions from the textbook:

Programming Project 4.10
>From the Alice Gallery, choose a clock class that has subparts for the
minute and hour hands.

a. Build a clock method named *run ( )* that moves the minute and hour
hands realistically (that is, each time the minute hand compeltes a
rotation, the hour hand should advance 1 hour). Define a parameter named
*speedUp* that controls the duration of the hand movements, such that* run
(0) *will make the clock run at normal speed, *run (60)* will make the
clock run at 60 times its normal speed, run* (3600) *will make the clock
run at 3600 its normal speed, and so on.

b. Build a clock method *setTime(h, m)* that sets the clock's time to *h:m*
(*m* minutes after hour *h*).

c. Build three functions for your clock: one that returns its current time
(as a *String*), one that returns its current hours value (as a *Number*),
and one that returns its current minutes value (as a *Number*).

d. Build a clock method *setAlarm (h, m) *that lets you set the clock's
alarm to *h:m.*  Then modify your *run( ) *method so that when the clock's
current time is equal to *m* minutes after hour *h*, the clock plays a
sound.

Any ideas or suggestions would be appreciated.  Thanks so much!

Denise Nichols
*Computer Teacher*
*York Catholic High School*
*dnichols at yorkcatholic.org <dnichols at yorkcatholic.org>*
*717-846-8871*

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20161026/c6498b8a/attachment.html>


More information about the alice-teachers mailing list