• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help Please??  RSS feed

 
William Joel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can you pull this off?

I understand the use of a constructor, but I have never had to return the constructor type back to the main program.


Snippet from the main program:


[ September 17, 2006: Message edited by: William Joel ]



I have to create a class named CalendarDate that will return an object of type CalendarDate after calling the constructor. So far no problem.

Starting on the line "CalendarDate x = birthDate.next();" this is specifying that I have to return a CalendarDate type from the birthDate.next(). That is where I am lost.

It is a school lab, I can't alter the code in the main program.
[ September 17, 2006: Message edited by: William Joel ]
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you elaborate on your question?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

I'm afraid I don't understand the question either. Are you looking for a toString representation of CalendarDate?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what your disconnect is either. The first line:

CalendarDate birthDate = new CalendarDate(2,28,2004);


creates an instance of CalendarDate and assigns its reference to birthDate. Now birthDate refers to the newly-created instance in remaining references.

So the second line:

CalendarDate x = birthDate.next();


calls a next() method on that instance. From this line I would expect that the next() method returns a new instance of CalendarDate that is computed and created within that method.
[ September 17, 2006: Message edited by: Bear Bibeault ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Joel:
...I have to create a class named CalendarDate that will return an object of type CalendarDate after calling the constructor. So far no problem.

Starting on the line "CalendarDate x = birthDate.next();" this is specifying that I have to return a CalendarDate type from the birthDate.next(). That is where I am lost...

So in your class CalendarDate, you have a method called "next()" that returns another instance of CalendarDate, right? What does your code look like for the "next()" method?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, please try to choose subject titles that describe your problem. "Help please??" doesn't convey any information regarding your issue. Please read this for more information.
[ September 17, 2006: Message edited by: Bear Bibeault ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!