📄 concretestudentmanager.java
字号:
package myprojects.studymanager;
import java.util.*;
import java.lang.*;
import java.io.*;
public class ConcreteStudentManager extends AbstractStudentManager
implements Serializable{
List StuManager;
public ConcreteStudentManager(List Stu)
{
StuManager=Stu;
}
public boolean addStudent(AbstractStudent student) throws SameStudentIDException
{
if(StuManager.contains(student))
throw new SameStudentIDException();
else
StuManager.add(student);
return true;
}
public AbstractStudent removeStudent(String studentID) throws StudentNotFoundException
{
AbstractStudent temp=new GraStudent("temp",0,studentID,"temp",0,0);
int index =StuManager.indexOf(temp);
if(index==-1)
throw new StudentNotFoundException();
AbstractStudent removeStu=(AbstractStudent)(StuManager.get(index));
StuManager.remove(temp);
return removeStu;
}
public AbstractStudent NamesearchStudent(String name) throws StudentNotFoundException
{
ListIterator it=StuManager.listIterator();
while(it.hasNext())
{
AbstractStudent next=(AbstractStudent)(it.next());
// System.out.println(name+"1");
// System.out.println(next.getS_name()+"1");
if(name.equals(next.getS_name()))
{
return next;
}
}
throw new StudentNotFoundException();
}
public AbstractStudent IDsearchStudent(String studentID) throws StudentNotFoundException
{
AbstractStudent temp=new GraStudent("temp",0,studentID,"temp",0,0);
int index =StuManager.indexOf(temp);
if(index==-1)
throw new StudentNotFoundException();
return (AbstractStudent)(StuManager.get(index));
}
public void showAllStudentsInfo()
{
ListIterator it=StuManager.listIterator();
while(it.hasNext())
{
((AbstractStudent)(it.next())).showStudentInfo();
System.out.println("\n");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -