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

📄 logincheck.java

📁 国外的数据结构与算法分析用书
💻 JAVA
字号:
package Commands;

import Interfaces.Interface;
import People.Staff;
import Sets.StaffSetAccess;
import dslib.exception.ItemNotFoundUosException;

/**	Check that the id entered is valid.  */
public class LoginCheck
{
	/**	Is the id entered by the person using loginInterface valid?
		Analysis: Time = O(log(StaffSet.size)) */ 
	public static boolean valid(int id, Interface loginInterface)
	{
		Staff user = null;
		try
		{
			user = (Staff) StaffSetAccess.dictionary().obtain(new Integer(id));
		} catch (ItemNotFoundUosException e) 
		{
			loginInterface.sendMessage("****Invalid id. Session terminated.");
			return false;
		}
		String password = loginInterface.getPassword();
		if (password.equals(user.password()))
			return true;
		else
		{
			loginInterface.sendMessage("****Incorrect password. Session terminated.");
			return false;
		}
	}
}

⌨️ 快捷键说明

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