Homework 1
comp 125-609, Goldwasser
Due: 6:00pm Tuesday, September 14, 1999 (worth 5 points)
Late Option: if submitted between 6:00pm September 14 and 6:00pm
September 21, you can recieve up to 3 of 5 points. No late homeworks
will be accepted after 6:00pm September 21.
Purpose: To get more experience using Events, writing code
using decision structures, and defining and using your own
variables.
Requirements:
In this assignment, we will modify the Stop Light program which
we used in Lab 2. Rather than
operating the light manually, we will make the stoplight run on a
timer, where the interval of time for each color light is
chosen by the user.
Here is what is required of functionality:
You may assume that you have a nice user who always enters valid
intervals (that is integers, greater than or equal to one). We
will work on ways to enforce this in later assignments.
A sample of a working program can be downloaded from,
www.math.luc.edu/~mhg/comp125/homework/sampHW1.exe
.
Advice:
For starters, you will need to use a new type of control called a
Timer. This control is not discussed in the textbook. The control
icon is located in the left column of the tool box and it looks like a
stopwatch. For this assignment, the relative features of this object
are:
You will most likely need to use If-Then-Else blocks or Select-Case
blocks, as described in Section 3.1 of the text.
You will most likely need to create and use global
variables to keep track of information (such as, which is the current
color displayed, is the timer currently activated).
Here is a a useful fact for this program (and for many
programs in the future). The Form has an event called "Load"
which is guaranteed to be called once at the beginning of your
program's execution. This is a very useful event for initializing any
global variables.
Extra Credit (1 point):
Combine the functionality of both the manual light and the timed
light. That is, when the timer is set to off, allow the user to go
back to operating the light manually. Note, this is what is often
done in a case where a police officer at an intersection can
override the light and control it manually.
Although this extra credit seems like a simple task of combining the
lab and the original homework, it actually involves quite a bit more
work to get correct. (certainly should be worth more than 1 point
extra -- although it is not!)
Keep in mind that when the timer is running, you do NOT want to allow
the user to control the light using either clicks or the Tab button so
you should disable all of the picture boxes.
You want the two modes to interact seemlessly. That is, whichever
light is left on by the manual mode should be the first light used in
timer mode. Similarly, whichever light is on when the timer is turned
off should remain lit as manual mode is resumed.
A sample of a working extra credit program can be downloaded from,
www.math.luc.edu/~mhg/comp125/homework/sampHW1extra.exe .
To submit your homework you should,