Lab 7 :: Getting started with classes

This lab is to make you comfortable in working with classes.

You are given a simple class Date here Date_Stub.java. Fill in the code for the method to compare two dates.

Design a class Address. It should have fields (member variables) for city & state. Include other fields like; house no., locality etc. as you wish. The class should have a constructor and a toString method also.

Outline of a class Person is here Person.java. The class has several static methods for sorting/searching etc. which you are asked to implement.

You can start with the code for bubblesort or binarysearch from the website, your job is to adapt this code to work for an array of persons instead of an array of a primitive type. Specification of each method is given before its header.

You can use the following method for comparing two strings.

String class has a method int compareTo(String str). This works as follows.

If s and t are String objects then s.compareTo(t) returns

a negative integer if s precedes t in dictionary order.

a positive integer if t precedes s in dictionary order.

integer zero if t and s are equal.