/**
* BugDemoApp.java
*
*
* Created: Sat Jan 11, 2003
*
* @author Stuart C. Shapiro
*
* Demonstrates the usefulness of Java assertions and exceptions.
*/
public class BugDemoApp {
/**
* Prints n
, formatted as a 10-digit phone number,
* with the comment that it is a possible phone number.
*
* pre: n
.length == 10.
*
* post: n
is printed as a 10-digit phone number,
* formatted as a phone number,
* with the comment that it is a possible phone number.
*
* @param n a 10-digit String
.
*/
public static void CheckPhoneNumber (String n) {
System.out.println(n.substring(0,3) + "-" + n.substring(3,6)
+ "-" + n.substring(6)
+ " is a possible phone number.");
}
/**
* Driver for BugDemoApp,
* demonstrating a bug due to a failed precondition.
*
*/
public static void main (String[] args) {
CheckPhoneNumber("7165551234");
CheckPhoneNumber("201467");
} // end of main ()
}// BugDemoApp