|
-
Urgent Problem with Display Method in Java
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
Similar Threads
-
By lacanaupro in forum Java
Replies: 0
Last Post: 05-21-2005, 05:00 PM
-
By ramanand in forum Java
Replies: 0
Last Post: 10-17-2000, 05:34 AM
-
Replies: 6
Last Post: 10-09-2000, 11:46 AM
-
By JJ in forum Enterprise
Replies: 1
Last Post: 07-06-2000, 04:50 AM
-
Replies: 3
Last Post: 06-09-2000, 08:18 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks