concretestudentmanager.java

来自「一个学籍管理系统。」· Java 代码 · 共 69 行

JAVA
69
字号
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 + =
减小字号Ctrl + -
显示快捷键?