Fund. CS II (CS152 2004F)

Class 15: Laboratory: Java Basics, Continued

Back to Laboratory: Java Basics, Revisited. On to Standard Object Methods.

Held: Tuesday, 21 September 2004

Summary: Today we continue check our understanding of Java basics by writing some more simple Java programs.

Related Pages:

Assignments

Notes:

Preparation

All of today's work should be in package userid.lab02. Please create and share the appropriate directories.

Exercise 1: A Date Interface

Write a Java interface called Date that describes the following methods:

Exercise 2: A Date Implementation

a. Write a Java model class called DateV1 that implements the Date interface. This class should have three fields: year, month, and dayofmonth. You do not need to worry about leap years.

b. Write a Java main class called TestDateV1 that creates a DateV1 with today's date and pritns the result of each of the methods in the class.

Exercise 3: Another Date Implementation

a. Write a Java mold class called DateV2 that implements the Date interface. This class should have only two fields: year and dayofyear.

b. Write a Java main class called TestDateV2 that creates a DateV2 with today's date and pritns the result of each of the methods in the class.

Back to Laboratory: Java Basics, Revisited. On to Standard Object Methods.

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Wed Dec 8 10:37:12 2004.
The source to the document was last modified on Thu Aug 26 20:22:22 2004.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS152/2004F/Outlines/outline.15.html.

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky, rebelsky@grinnell.edu