📄 tryphonebook.java
字号:
class TryPhoneBook
{
public static void main(String[] args)
{
PhoneBook book = new PhoneBook(); // The phone book
FormattedInput in = new FormattedInput(); // Keyboard input
Person someone;
for(;;)
{
System.out.println("Enter 1 to enter a new phone book entry\n"+
"Enter 2 to find the number for a name\n"+
"Enter 3 to list all the entries\n" +
"Enter 4 to quit.");
int what = in.intRead();
switch(what)
{
case 1:
book.addEntry(BookEntry.readEntry());
break;
case 2:
someone = Person.readPerson();
BookEntry entry = book.getEntry(someone);
if(entry == null)
System.out.println("The number for "+someone +
" was not found. ");
else
System.out.println("The number for "+someone +
" is " + book.getEntry(someone).getNumber());
break;
case 3:
book.listEntries();
break;
case 4:
book.save();
System.out.println("Ending program.");
return;
default:
System.out.println("Invalid selection, try again.");
break;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -