ATM管理系统

//菜单界面(Menu.java类)

package ATM;

public class Menu {;
    //菜单
        public void menu(){
            System.out.println("----------------------");
            System.out.println("|    欢迎进入ATM机系统        |");
            System.out.println("|    1注册                                |");
            System.out.println("|    2登录                                |");
            System.out.println("|    欢迎进入ATM机系统        |");
            System.out.println("----------------------");
            System.out.println("请输入整数序号:");
        }
         
        public void welcome(Account account){
            System.out.println("----------------------");
            System.out.println("   欢迎"+account.getName()+"进入ATM机系统");
            System.out.println("|    1查询余额                        |");
            System.out.println("|    2存款                                |");
            System.out.println("|    3取款                                |");
            System.out.println("|    4退出                                |");
            System.out.println("----------------------");
            System.out.println("请输入整数序号:");
        }
     
    }

//测试界面(Atmtext.java类)

package ATM;
 
    import java.util.Scanner;
    //ATM测试类
    public class AtmTest {
        public static void main(String[] args) {
             
            Menu m=new Menu();
            Scanner sc=new Scanner(System.in);
            RegisAndLogin r=new RegisAndLogin();
            Account a=new Account(17159,123456,"殷乐天",20,10000);
            boolean b=false;
            Operation o=new Operation();
            //主菜单界面
            while(true){
                m.menu();
                int index=sc.nextInt();
                if(index==1){
                    //注册
                    b=r.regis(a, sc);
                    if(b){
                        System.out.println("注册成功!");
                        System.out.println(a.getName()+"------初始账户余额:"+a.getMoney());
                    }else{
                        System.out.println("注册次数用完,请明天再来!");
                    }
                     
                }else if(index==2){
                    //登陆
                    b=r.login(a, sc);
                    if(b){
                        System.out.println("登陆成功,欢迎"+a.getName()+"用户!");
                        break;
                    }else{
                        System.out.println("登陆次数用完,请明天再来!");
                    }
                }
            }
            //操作界面
            if(b){
                while(true){
                    m.welcome(a);
                    int index=sc.nextInt();
                    if(index==1){
                        //查询余额
                        o.findMoney(a, sc);
                    }else if(index==2){
                        //存款
                        o.addMoney(a, sc);
                    }else if(index==3){
                        //取款
                        o.putMoney(a, sc);
                    }else{
                        //退出
                        break;
                    }
                }
                 
            }
        }
     
    }
     

//开户,销户(Account.java类)

package ATM;

    public class Account {
        private int username;
        private int password;
        private String name;
        private int age;
        private int money;
        
        public int getUsername() {
            return username;
        }
        public void setUsername(int username) {
            this.username = username;
        }
        public int getPassword() {
            return password;
        }
        public void setPassword(int password) {
            this.password = password;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public int getAge() {
            return age;
        }
        public void setAge(int age) {
            this.age = age;
        }
        public int getMoney() {
            return money;
        }
        public void setMoney(int money) {
            this.money = money;
        }
        public Account(){
             
        }
        public Account(int username, int password, String name, int age, int money) {
            this.username = username;
            this.password = password;
            this.name = name;
            this.age = age;
            this.money = money;
        }
    }

//登录注册(RegisAndlogin.java)

package ATM;
     
    import java.util.Scanner;
    //登陆、注册类
    public class RegisAndLogin extends Account{
        //boolean用于判断是否注册成功
        public boolean regis(Account account,Scanner sc){
            System.out.println("请输入整数型的注册账户:");
            int uname=sc.nextInt();
            for(int i=0;i<3;i++){
                System.out.println("请输入整数型的账户密码:");
                int pword=sc.nextInt();
                System.out.println("请二次输入密码:");
                int pword2=sc.nextInt();
                if(pword==pword2){
                    //成功
                    account.setPassword(pword);
                    break;
                }else{
                    System.out.println("两次输入密码不正确!");
                    if(i==2){
                        return false;
                    }
                }
            }
            System.out.println("请输入用户名:");
            String name=sc.next();
            System.out.println("请输入年龄:");
            int age=sc.nextInt();
            account.setMoney(10000);
            account.setUsername(uname);
            account.setName(name);
            account.setAge(age);
            return true;
                     
        }
        //boolean用于判断是否登陆成功
        public boolean login(Account account,Scanner sc){
            System.out.println("请输入账户名:");
            for(int i=0;i<3;i++){
                int uname=sc.nextInt();
                if(uname==account.getUsername()){
                    //账号正确
                    break;
                }else{
                    System.out.println("不存在此账户!请重新输入:");
                    if(i==2){
                        return false;
                    }
                }
            }
             
            System.out.println("请输入账户密码:");
            for(int j=0;j<3;j++){
                int pword=sc.nextInt();
                if(pword==account.getPassword()){
                    //密码正确
                    break;
                }else{
                    System.out.println("密码有误!请重新输入:");
                    if(j==2){
                        return false;
                    }
                }
            }
             
            return true;
             
        }
     
    }

//存款,取款(Operation.java)

package ATM;
 
    import java.util.Scanner;
     
    public class Operation {
         
        public void addMoney(Account account,Scanner sc){
            System.out.println("请输入存款数额:");
            int money=sc.nextInt();
            if(money>0){
                account.setMoney(money+account.getMoney());
                System.out.println("存款成功!");
            }else{
                System.out.println("存款数额不能为零或负!");
            }
        }
         
        public void findMoney(Account account,Scanner sc){
            System.out.println("您的余额为:"+account.getMoney());
        }
         
        public void putMoney(Account account,Scanner sc){
            System.out.println("请输入你的取款额:");
            int money=sc.nextInt();
            if(0<money&&money<account.getMoney()){
                System.out.println("取款成功!");
                account.setMoney(account.getMoney()-money);
            }else{
                System.out.println("余额不足!");
            }
        }
     
    }

 

psp2.1 任务内容 计划完成需要的时间(min) 实际完成需要的时间(min)
Planning 计划 10 20
Estimate 估计这个任务需要多少时间,并规划大致工作步骤 10 12 
Development 开发 300 400
Analysis 需求分析(包括学习新技术) 12
Design Spec 生成设计文档 5
Design Review 设计复审 5
Coding Standard 代码规范 5 10 
Design 具体设计 10 12 
Coding 具体编码 300 300 
Code Review 代码复审 5 75
Test 测试(自我测试,修改代码,提交修改) 10 15 
Reporting 报告 50 60 
Test Report 测试报告 3
Size Measurement 计算工作量 2 13
Postmortem & Process Improvement Plan 事后总结,并提出过程改进计划 5 35
posted @ 2020-11-18 19:40  是你们的lotte呀  阅读(110)  评论(0编辑  收藏  举报