门禁系统
来源:互联网 发布:苏州新区淘宝培训 编辑:程序博客网 时间:2024/04/28 16:55
package com.ytdx.user;
import java.util.Scanner;import com.ytdx.sys.Door;public class Guest {private String name;public String getName() {return name;}public void setName(String name) {this.name = name;}public Guest(){}public Guest(String name){this.name=name;}public void pressRing(Door door){System.out.println("Guest:"+name+"按门铃 ,请开门:y/n");Scanner in=new Scanner(System.in);String btn=in.nextLine();if(btn.equals("y")){door.setBellstate(true);System.out.println(name+"按下了门铃");}elseSystem.out.println(name+"已离开");}}
package com.ytdx.user;import java.util.Scanner;public class Employee extends Guest{public Employee(){}public Employee(String name){//this.setName(name);super(name);}public String input(){System.out.println("请输入密码:");Scanner in=new Scanner(System.in);String str=in.nextLine();return str;}}
package com.ytdx.user;import java.util.Scanner;import com.ytdx.sys.Door;public class Admin extends Employee {public Admin(){}public Admin(String name){super(name);//setName(name);}public void work(Door door){if(door.isBellstate()){System.out.println(getName()+"门铃响了,开门么(y/n)");Scanner in=new Scanner(System.in);String bn=in.nextLine();if(bn.equals("y")){System.out.println("门已开,请进");door.open();try{ Thread.sleep(5000); }catch(InterruptedException e){ e.printStackTrace(); }System.out.println("门已关");door.close();}else{System.out.println("门没开");door.close();}}}}
package com.ytdx.sys;public class Door {private boolean state;private boolean bellstate;public boolean isState() {return state;}public void setState(boolean state) {this.state = state;}public boolean isBellstate() {return bellstate;}public void setBellstate(boolean bellstate) {this.bellstate = bellstate;}public Door(){this.state=false;this.bellstate=false;}public Door(boolean state,boolean bellstate){this.state=state;this.bellstate=bellstate;}public void open(){this.state=true;}public void close(){this.state=false;}}
package com.ytdx.sys;public class Computer {public boolean validate(String pass){if(pass.equals("123")){System.out.println("验证通过");return true;}else{System.out.println("验证不通过");return false;}}}
package com.ytdx.text;import java.util.Scanner;import com.ytdx.sys.Computer;import com.ytdx.sys.Door;import com.ytdx.user.Admin;import com.ytdx.user.Employee;import com.ytdx.user.Guest;public class Text {//private static Object contain;/** * @param args */public static void main(String[] args) {//Door door=new Door();//Guest guest=new Guest("张三");//guest.pressRing(door);//Admin admin=new Admin("张张");//admin.work(door);//Employee e1=new Employee("李四");//String pass=e1.input();//Computer c1=new Computer();//boolean result=c1.validate(pass);//if(result){//door.open();//System.out.println("门已开");//}//else{//door.close();//System.out.println("门已关");//}Door door=new Door();Guest guest=new Guest();Admin admin=new Admin("管理员"); Employee emp=new Employee(); Computer c=new Computer(); while(true){ System.out.println("1:访客 2:雇员"); Scanner in=new Scanner(System.in); int bn=in.nextInt(); switch(bn){ case 1: System.out.println("尊敬的访客,请输入您的姓名:"); Scanner Name=new Scanner(System.in); String GuestName=Name.nextLine(); guest.setName(GuestName); guest.pressRing(door); admin.work(door); continue; case 2:if(c.validate(emp.input())){ door.open(); System.out.println("门已开"); try{ Thread.sleep(5000); }catch(InterruptedException e){ e.printStackTrace(); } door.close(); System.out.println("门已关"); }continue; } } }}
0 0
- 门禁系统
- 门禁系统
- 门禁系统
- 门禁系统
- 门禁系统
- 门禁系统
- 门禁系统
- 门禁系统
- 门禁系统
- 门禁系统
- 门禁系统
- 门禁系统
- 门禁系统
- 门禁系统设计方案
- 谈谈FRID 门禁系统
- 金库门禁系统方案
- 实战门禁系统经历
- 门禁系统入门常识
- 搭建移动端框架Ionic+Genymotion开发环境
- spring mvc 关于乱码的几种解决方式
- Linux无锁编程
- 手机抓包总发现东北大学IP,你需要知道的NTP服务器
- ACM--约数--HDOJ 1492--The number of divisors(约数) about Humble Numbers
- 门禁系统
- 1012. 数字分类 (20)
- 【2016杭电女生赛1005】【暴力 bfs or dfs or 模拟】girlcat 数女生数和猫咪数
- CAS使用HTTPs功能遇到的问题
- String,StringBuffer与StringBuilder的区别??
- APP开发实战35-HTTPS的运作方式
- oralce case when 语句
- 编程为什么有趣?
- 数据结构实验之栈八:栈的基本操作