If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

using the "this" method in a constructor

When I attempt to compile the following class I get an error message
pointing to one of my constructors stating "wrong number of arguments in
constructor. Can anyone shed some light on what I am missing?
Thanks.

/********************************************************
* A public class used for *
* calculating and processing time values. *
********************************************************/

/**********************************************************
* A public method that converts the time input into
* universal time format. It tests the values of the current
* instance variables for proper digit length and
* then formats the output. Once the
* values are correctly set the method returns.
*----------------------------------------------------------
* usage: x = object.toUnversalString();
* object is a class object.
*----------------------------------------------------------
* returns a string in the 24 hour format of hh:mm:ss
***********************************************************/
public String toUniversalString()
{
String result = "",
tempHours = "",
tempMinutes = "",
tempSeconds = "";

/*******************************************************
* A public method that copies the time input into standard
* time format. It tests the values
* for proper digit length and formats the output. Once the
* values are correctly set the method returns.
* returns a string in the 12 hour format of hh:mm:ss AM/PM.
*********************************************************/
public String toString()
{
String result = "",
tempHours = "",
tempMinutes = "",
tempSeconds = "",
amPm = "AM";

/*************************************************************
* A private method that converts any single digit
* integers to a two digit integer by adding a "0" preceeding
* the integer that was passed in as the argument.
* returns a two digit integer
*************************************************************/
private String twoDigits(int digits)
{
String tempDigits = "";

/***************************************************************
* A public method that tests the current object against one
* that is passed in as an arguement for equality.
* returns true if they are equal and or false if they are not.
****************************************************************/
boolean equals(MyTime otherObject)
{
return ( (this.mHours == otherObject.mHours)
&& (this.mMinutes == otherObject.mMinutes)
&& (this.mSeconds == otherObject.mSeconds) );
} //end equals(MyTime otherObject)
}

Re: using the "this" method in a constructor

You don't have any constructor which has 3 parameters. When you call this(
hours, 0, 0 ); compiler looks for the constructor with 3 int parameters.
In your following code you don't have any constructor which matches the
above. You have a method public void MyTime( int hours, int minutes, int
seconds ) but this is not a constructor. Constructors won't be having any
return type not even void. If you remove the void from the above method
signature your code will be compiled.