📄 concretestudentmanager.java
字号:
import java.util.*;
public class ConcreteStudentManager extends AbstractStudentManager
{
List list;
public ConcreteStudentManager()
{
list=new ArrayList();
}
public boolean addStudent(AbstractStudent student) throws SameStudentIDException
{
for(int i=0;i<list.size();i++)
{
AbstractStudent mystudent=(AbstractStudent)list.get(i);
if(mystudent.getStudentID()==student.getStudentID())
throw new SameStudentIDException(student.getStudentID());
}
list.add(student);
return true;
}
public AbstractStudent removeStudent(int studentID) throws StudentNotFoundException
{
for(int i=0;i<list.size();i++)
{
AbstractStudent mystudent=(AbstractStudent)list.get(i);
if(mystudent.getStudentID()==studentID)
return mystudent;
}
throw new StudentNotFoundException(studentID);
}
public AbstractStudent searchStudent(String name) throws StudentNotFoundException
{
for(int i=0;i<list.size();i++)
{
AbstractStudent mystudent=(AbstractStudent)list.get(i);
if(mystudent.getName()==name)
return mystudent;
}
throw new StudentNotFoundException(name);
}
public AbstractStudent searchStudent(int studentID) throws StudentNotFoundException
{
for(int i=0;i<list.size();i++)
{
AbstractStudent mystudent=(AbstractStudent)list.get(i);
if(mystudent.getStudentID()==studentID)
return mystudent;
}
throw new StudentNotFoundException(studentID);
}
public void showAllStudentsInfo()
{
for(int i=0;i<list.size();i++)
{
AbstractStudent mystudent=(AbstractStudent)list.get(i);
mystudent.showStudentInfo();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -