Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Check incoming String for 10 digit number and making sure each digit is a numeral 0-9

 
Kofi Nimako
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All:
I am developing a telephone class and I have all set up as follows:


class Telephone
{

String telephoneNumber;
String name;
double amountOwed ;

public Telephone()
{
telephoneNumber ="";
name ="";
amountOwed = 0.0;
}

public Telephone(String s,String inName,double inAmountOwed)
{
setTelephone(s );
setName ( inName );
setAmountOwed ( inAmountOwed );
}

public String getTelephone()
{
return telephoneNumber;
}

public String getName()
{
return name;
}

public double getAmountOwed()
{

return amountOwed;
}

/**
* A setTelephone Method
*/
public void setTelephone( String s )
{

telephoneNumber = s.substring(0,10);
}

Please How do I complete the setTelephone( String s ) method above that will check the incoming telephone number to make sure that it has ten digits and that every digit is numeral between 0 and 9.?

Thanks


:roll:
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does this have to do with Servlets? Moving to Java In General (Intermediate)
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic