📄 mailsystem.java
字号:
import java.util.ArrayList;
/**
A system of voice mail boxes.
*/
public class MailSystem
{
/**
Constructs a mail system with a given number of mailboxes
@param mailboxCount the number of mailboxes
*/
public MailSystem(int mailboxCount)
{
mailboxes = new ArrayList();
// Initialize mail boxes.
for (int i = 0; i < mailboxCount; i++)
{
String passcode = "" + (i + 1);
String greeting = "You have reached mailbox " + (i + 1)
+ ". \nPlease leave a message now.";
mailboxes.add(new Mailbox(passcode, greeting));
}
}
/**
Locate a mailbox.
@param ext the extension number
@return the mailbox or null if not found
*/
public Mailbox findMailbox(String ext)
{
int i = Integer.parseInt(ext);
if (1 <= i && i <= mailboxes.size())
return (Mailbox) mailboxes.get(i - 1);
else return null;
}
private ArrayList mailboxes;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -