PDA

View Full Version : Java - Simple Error Message


WildChild
12-05-2006, 07:42 PM
public class TextMessage extends Account
{
private int sendersMobilePhoneNumber;
private int recipientMobileNumber;
private String dateOfMessage;

/**
* Constructor for objects of class TextMessages.
*/
public TextMessage(String customersCityAddress, int thePhoneNumber)
{
super(customersCityAddress, thePhoneNumber)
this.sendersMobilePhoneNumber = sendersMobilePhoneNumber;
this.recipientMobileNumber = recipientMobileNumber;
this.dateOfMessage = dateOfMessage;
}

}

This is my code, it is presenting me with the error: ';' expected on the line that is:
this.sendersMobilePhoneNumber = sendersMobilePhoneNumber;

.. i know it's something every so simple i've missed it must be, but i'm almost certain its right.. :confused: argh!

Any help is much appreciated..

*just as a note the code above is that of Thomas Hough - United Kingdom - UEA (we've had people steealing other peoples code)

nikkiH
12-05-2006, 07:51 PM
super(customersCityAddress, thePhoneNumber);

forgot the semi-colon.

WildChild
12-05-2006, 08:53 PM
lol :D chrz..

Now it's saying

cannot find the symbol - constructor Account(java.lang.String,int)

on line:
super(customersCityAddress, thePhoneNumber);

Gox
12-05-2006, 10:02 PM
super(customersCityAddress, thePhoneNumber); implies that the Account class has some constructor that matches this syntax,

i.e In the Account class there must be a constructor that looks like;
public Account(string address, int phonenumber)
{
...some code...
}

So the question is, does Account have a contructor that matches this syntax? If not, then that's the reason for you error.

WildChild
12-06-2006, 11:48 AM
Ok well the part you are referring to in the "Account" class has this:
public Account(String theCustomersName, int thePhoneNumber, String customersCityAddress)
{
customersName = theCustomersName;
phoneNumber = thePhoneNumber;
customersCityAddress = "";
}

I'm unsure as to what i've actually done wrong?

Spookster
12-06-2006, 01:52 PM
It looks like the constructor for your Account class has three parameters and you are only passing in two of them hence why it is complaining about the third one.

nikkiH
12-06-2006, 03:25 PM
public Account(String theCustomersName, int thePhoneNumber, String customersCityAddress)
{
customersName = theCustomersName;
phoneNumber = thePhoneNumber;
customersCityAddress = "";
}

That doesn't really make sense.
But it has 3 parameters, so if you call super, you have to pass 3 parameters.

WildChild
12-07-2006, 01:34 PM
Thanks for all you're help, i've sorted it now :)