⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linklist.java

📁 学生信息管理系统 还没有连数据库 ,界面做的也不是很好看
💻 JAVA
字号:
//定义链表类,通过链表完成各种操作
class LinkList
{
	Node m_FirstNode;
	LinkList()
	{
		m_FirstNode=null;
	}
	LinkList(Student data)
	{
		m_FirstNode=new Node(data);
	}

	//插入
	void insertAtBegin(Student data)//插入链表头部
	{

		if(m_FirstNode==null)
		       m_FirstNode=new Node(data);
		else
		       m_FirstNode=new Node(data,m_FirstNode);

	 }

	 //登陆
	 Student access(int a,int b)
	 {
		 Node ahead=m_FirstNode;
		 Node follow=ahead;
		 if(ahead==null){return null;}
		 else if((ahead.getData().getnumber()==a)&(ahead.getData().getpassword()==b))
		 {
			return ahead.getData();
		 }
		  else
		 {
			ahead=ahead.getNext();
			while(ahead!=null)
			{
			   if((ahead.getData().getnumber()==a)&(ahead.getData().getpassword()==b))
				{
					return ahead.getData();
				}
				follow=ahead;
				ahead=ahead.getNext();
			}
			return null;
		 }
	 }

	 //查找
	 Student search(int a)//根据学号查找
	 {
		 Node ahead=m_FirstNode;
		 Node follow=ahead;
		 if(ahead==null){return null;}
		 else if(ahead.getData().getnumber()==a)
		 {
			 return ahead.getData();
		 }
		 else
		 {
			 ahead=ahead.getNext();
			 while(ahead!=null)
			 {
				 if(ahead.getData().getnumber()==a)
				 {return ahead.getData();}
				 follow=ahead;
				 ahead=ahead.getNext();
			 }
			 return null;
		 }
	 }

	 Student search(String s)//根据姓名查找,注意字符串比较方法
	 {
		 Node ahead=m_FirstNode;
		 Node follow=ahead;
		 if(ahead==null){return null;}
		 else if(s.compareTo(ahead.getData().getname())==0)
		 {
			 return ahead.getData();
		 }
		 else
		 {
			 ahead=ahead.getNext();
			 while(ahead!=null)
			 {
				 if(s.compareTo(ahead.getData().getname())==0)
				 {return ahead.getData();}
				 follow=ahead;
				 ahead=ahead.getNext();
			 }
			 return null;
		 }
	  }

	   //先查找查找出具体资料,再决定要不要删除
	  String removeAtId(Student id)
	  {
		  String s;
		  Node ahead=m_FirstNode;
		  Node follow=ahead;
		  if(ahead==null)s="表空,删除失败";
		  else if(ahead.getData()==id)
		  {
			   m_FirstNode=m_FirstNode.getNext();
			   s="删除成功";
		  }
		  else
		  {
			   ahead=ahead.getNext();
			   while(ahead!=null)
				{
					if(ahead.getData()==id)
					{
						follow.setNext(ahead.getNext());
						s="删除成功";
					 }
					 follow=ahead;
					 ahead=ahead.getNext();
				  }
				  s="删除失败";
			 }
			 return s;
		 }

	//修改操作也是在查找操作上进行下一步,替换所有资料
	 void  modefy(Student m,int a,String s1,String s2,String s3,String s4,String s5,String s6,long l)
	 {
		 m.setall(a,s1,s2,s3,s4,s5,s6,l);
	 }

	 //删除链表中所有的数据信息
	 void removeAll()
	 {
		 m_FirstNode=null;
	 }

	 //返回链表中所有的数据信息
	 String returnall()
	 {
		 String s="下面是所有学生的资料:\n学号\t姓名\t性别\t系别\t年级\t生日\t地址\t电话\n\n";
		 Node ahead=m_FirstNode;
		 Node follow=ahead;
		 if(ahead==null)
		 	s="表空,无数据";
		 else
		 {
		 	while(ahead!=null)
		 	{
				s=s+ahead.getData().getnumber()+"\t"+ahead.getData().getname()+"\t"+ahead.getData().getsex()+"\t"
				+ahead.getData().getsdept()+"\t"+ahead.getData().getgrade()+"\t"+ahead.getData().getbirthday()+"\t"
				+ahead.getData().getaddress()+"\t"+ahead.getData().getphone()+"\n";
		 		follow=ahead;
		 		ahead=ahead.getNext();
		 	 }
		 }
		 return s;
	 }
 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -