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

📄 logininterface.java

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

import java.io.*;

/**	A basic interface for users of the registration system. */
public class LoginInterface
{
	BufferedReader input = null;
	
	/**	constructor */
	public LoginInterface()
	{
		input=new BufferedReader(new InputStreamReader(System.in));
	}
	
	/**	User Input
		Prompt the user with a menu so they can choose
		how they wish to login into the system. */
	public int getUserType()
	{
		int choice=0;
		System.out.println("\n What type of user are you : ");
		System.out.println(" ***************************");
		System.out.println(" 1. Instructor");
		System.out.println(" 2. Dept./College Admin");
		System.out.println(" 3. Student");
		System.out.println(" 4. Registrar");
		System.out.println(" 99. Quit");
		return (int)readInput("\n Enter your choice : ");
	}
	
	/**	Prompt the user for a personal access code */
	public int getPAC()
	{
		return (int)readInput("\nEnter your personal access code : ");
	}
	
	/**	Prompt the user for a student number */
	public int getStudentNumber()
	{
		return (int)readInput("\nEnter student number : ");
	}
	
 	/**	Prompt the user for a password */
	public String getPassword()
	{
		return readString("\nEnter your password :  ");
	}
	
	/**	 Prompt the user for their name*/
	public String getName()
	{
		return readString("\nEnter your name : ");
	}


	/**	Read in a double value */
	public double readInput(String msg)
	{
		/**	assume the worse from start */
		boolean badChoice = true; 
		double theChoice = -1;	
	
		do
		{
			System.out.print(msg);
			try
			{
				//theChoice = Double.parseDouble(IO.readInput());
				theChoice = Double.parseDouble(input.readLine());
			} catch (Exception e) {}
		
			if (theChoice <= 0)
				System.out.println("Invalid input" + ". Try again! ");
			else
				badChoice = false;
		} while (badChoice);
		return theChoice;
	}

		/**	Read in a double value */
	public String readString(String msg)
	{
		/**	assume the worse from start */
		boolean badChoice = true; 
		String theChoice = "";	
	
		do
		{
			System.out.print(msg);
			try
			{
				//theChoice = IO.readInput();
				theChoice = input.readLine();
			} catch (Exception e) {}
		
			if (theChoice.equals(""))
				System.out.println("Invalid input" + ". Try again! ");
			else
				badChoice = false;
		} while (badChoice);
		return theChoice;
	}

	/**	Tell the user that they have made an invalid choice */
	public void showInvalidChoice()
	{
		System.out.println("\nInvalid choice.");
		System.out.println("\nPlease make another selection.");
	}

} /* end of LoginInterface */

⌨️ 快捷键说明

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