CS 3291 (Java with Internet Applications):
Homework #1

Assigned:
September 10, 1999.
Due:
September 17, 1999, class time.
Credit:
10 points.
Objective:
Define and use a class.
Description:
You are to implement a simple Clock class, with a constructor method and methods to reset the clock, increment its value, and display its value. The template code gives details.
Instructions:
  1. Download template source code (Clock.java).
  2. Replace comments of the form
    // Your code/declarations go here.
    with declarations and code to implement the methods as described in the comments. Also replace your name, SSN, and e-mail address in the comments at the top of the source code, and (optionally) fill in the "time spent" comment.
  3. Test the program until you are satisfied that it works. See Java tips for help with compiling and executing.
  4. Submit as described in How to submit homework.
Grading:
This homework is worth 10 points:
Helpful hints:
  1. Here are some methods you may find useful. These methods are part of the standard language package; you do not need any import statements to use them.
    • Integer.parseInt(String s) returns an integer; e.g. Integer.parseInt("10") returns the integer 10.
    • System.out.print(String s) and System.out.println(String s) print strings to standard output, without and with (respectively) an end-of-line marker. If you call either method with an argument that is not a string, the argument will be converted into a reasonable printable representation and written to standard output.
    • If s1 and s2 are strings, s1.equals(s2) returns a boolean indicating whether the two strings have the same value. (The expression s1 == s2 compares not the values of the strings but the values of the references, and thus yields true only when s1 and s2 are the same object.)
  2. Recall that + denotes concatenation when applied to strings, and note that you can convert anything to a string by concatenating it with another string. For example, the value of "ab" + 10 is a string with value "ab10".