Hi...I am having some problems with a very basic Java project I am doing.
I have problems displaying a phone Number with a space after the first four digits.
The phoneNumber variable was declared like this using Boolean, and it works fine.
------------------------
PhoneNumber
-----------------------------
public String getaPhoneNumber ()
{
return phoneNumber;
}
public boolean setPhoneNumber (String aPhoneNumber)
{
if (aPhoneNumber.length () <= 7)
{
return false;
}
if (aPhoneNumber.length () == 9)
{
return false;
}
if (aPhoneNumber.length () >= 11)
{
return false;
}else {
phoneNumber = aPhoneNumber;
return true;
}
}
-----------------------------------------------------------
This is the display bit of the code:
----------------------------------------------------------------
public void display()
{
System.out.println(name);
System.out.println(streetAddress);
System.out.println(suburb + " " + postCode);
System.out.println("Phone:" + " " + phoneNumber);
}
------------------------------------
It is supposed to display itself like this in BlueJ:
Fred
9451 3353
25 Brown Street
Box Hillsborugh
VIC 3111
---------------------------------
(i cant seem to display the space for the phone number after the first 4 digits as shown above)
Any help would be appreciated.
Many Thanks


Reply With Quote


Bookmarks