Skip to content

Instantly share code, notes, and snippets.

Created September 1, 2012 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3578618 to your computer and use it in GitHub Desktop.
Save anonymous/3578618 to your computer and use it in GitHub Desktop.
public class Main {
public static void main(String[] args) {
int x;
PhoneBook pb = new PhoneBook();
System.out.println(pb);
x = pb.nextIndex();
if(x != -1) {
pb.setName("Bob", x);
pb.setNumber("0987654321", x);
}
else {
System.out.println("Error: No empty phone book entries.");
}
pb.setName("Mike", 0);
pb.setNumber("1234567890", 0);
pb.setName(null, 1);
pb.setNumber(null, 1);
System.out.println(pb);
x = pb.nextIndex();
if(x != -1) {
pb.setName("Bob", x);
pb.setNumber("0987654321", x);
}
else {
System.out.println("Error: No empty phone book entries.");
}
System.out.println("Entry for Mike at index: " + pb.getRecord("mike"));
System.out.println("Entry number 2 (index 1) is: ");
String temp[] = pb.getRecord(1);
if(temp != null) {
System.out.println("\t" + temp[0]);
System.out.println("\t" + temp[1]);
}
else {
System.out.println("Null entry.");
}
System.out.println("\n" + pb);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment