效果显示:
controller
public class Supermarket { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { System.out.println("*********欢迎使用超市收银系统********"); System.out.println("1.会员登录\t2.员工登录\t0.退出系统"); System.out.println("请选择登录:"); LoginServiceImpl loginServiceImpl = new LoginServiceImpl(); String number; String password; switch (count(sc)) { case 1: System.out.println("请输入账号:"); number = sc.next(); System.out.println("请输入11位手机号码:"); password = IsPhoneNumber.isPhoneNumber(sc.next()); number=loginServiceImpl.vipLogin(number, password); new PageServiceImpl().vipPage(number); break; case 2: System.out.println("请输入账号:"); number = sc.next(); System.out.println("请输入密码:"); password = sc.next(); Employee employee = loginServiceImpl.employeeLogin(number, password); employeeSelect(employee); break; case 0: System.out.println("欢迎再次使用!"); System.exit(0); default: System.out.println("输入有误,返回主界面"); main(null); } } public static int count(Scanner sc) {//防止键盘输入错误 int i; while (true) { String s = sc.next(); if (s.length() > 1) { System.out.println("输入有误,返回主界面"); main(null); } else if (s.charAt(0) >= 48 && s.charAt(0) <= 51) { i = Integer.parseInt(s); break; } else { System.out.println("输入有误,返回主界面"); main(null); } } return i; } //判断员工种类 public static void employeeSelect(Employee employee){ PageServiceImpl psi = new PageServiceImpl(); if (employee.getRole()==1){ psi.adminPage(employee.getNumber()); }else if (employee.getRole()==2){ psi.cashierPage(employee.getNumber()); }else if (employee.getRole()==3){ psi.buyerPage(employee.getNumber()); } } }
gitee地址:
Supermarket-Project: 超市收银系统,包括会员登录和员工登录。员工分为管理员,收银员和管理员。每一位角色都有相应的权限。 (gitee.com)