NEED HELP!

I am running through the exercises in chapter 8 of How to Program 6th edition and I am totally stuck. I am trying to figure out 8.16 and I am really hitting a wall. If someone could get me going with it I would greatly appreciate it. I read other posts and to clarify this is NOT homework, I am trying to figure out some things and broaden my understanding. Here is what the book asks for:

Output the date in multiple formats, such as

MM/DD/YYYY

June 14, 1992

DDD YYYY

Use overloaded constructors to create Date objects initialized with dates of the formats in part (a). In the first case the constructor should receive three integer values. In the second case it should receive a String and two integer values. In the third case it should receive two integer values, the first of which represents the day number in the year. [Hint: To convert the string representation of the month to a numeric value, compare strings using the equals method. For example, if s1 and s2 are strings, the method call s1.equals( s2 ) returns true if the strings are identical and otherwise returns false.]

[1127 byte] By [HellKata] at [2007-11-27 7:56:14]
# 1
What's your question? http://java.sun.com/docs/books/tutorial/i18n/format/simpleDateFormat.html~
yawmarka at 2007-7-12 19:37:48 > top of Java-index,Java Essentials,Java Programming...
# 2

My question is how do I write the code with the overloaded constructors...I could get a date program to print out what the book asks for without needing the overloaded constructors but I would be missing the point of learning how to use them.

So the question is why are they needed and how do I use them, also how should I implement the s1.equals(s2) bit. I am kind of knocking my head on the wall here but I have been up all night trying to figure this out.

HellKata at 2007-7-12 19:37:48 > top of Java-index,Java Essentials,Java Programming...
# 3

If you keep in mind that a constructor's purpose is to initialize instances of the class, the typical usage of overloaded constructors becomes clear:

public class Foo {

private String s;

private int i;

public Foo() {

this("", -1);

}

public Foo(String s, int i) {

this.s = s;

this.i = i;

}

}

The problem describes why you would use an overloaded constructor; to initialize the class in different ways.

~

yawmarka at 2007-7-12 19:37:48 > top of Java-index,Java Essentials,Java Programming...
# 4
Ok so basically I just have to tell it to accept integers and strings in the overload constructor then?
HellKata at 2007-7-12 19:37:48 > top of Java-index,Java Essentials,Java Programming...
# 5

> Ok so basically I just have to tell it to accept

> integers and strings in the overload constructor then?

"In the first case the constructor should receive three integer values. In the second case it should receive a String and two integer values. In the third case it should receive two integer values, the first of which represents the day number in the year."

Three constructors: one that takes three int values, one that takes a String and two int values, and one that takes two int values. Since you have more than one constructor, the constructor is said to be "overloaded".

~

yawmarka at 2007-7-12 19:37:48 > top of Java-index,Java Essentials,Java Programming...