Wednesday, June 16, 2004

Exercise[24]

Read about and study the behavior of a traditional stopwatch. (Also read about has-a relationships!)

Then:
  1. Provide the missing JavaScript or Java code needed to complete this partial implementation of a traditional stopwatch.
  2. Use your implementation of a stopwatch to study how long it takes a JavaScript or Java for loop to increment a counter one billion times. What did you learn?
  3. List all of the distinct and worthwhile "sequences of events" that you should test to ensure that your implementation of a traditional stopwatch works correctly. For example:
    • Sequence of events: New stopwatch!, press Top. Expected result: displays 0.
    • Sequence of events: New stopwatch!, press Top, press Top. Expected result: displays a whole number greater than zero.
    • etc.