• 测试


    packag
    //信1905-2 陈涵 20194016
    package ceshi;
    public class Account {
    private String accountID;
    private String accountname;
    private String operatedate;
    private int operatetype;
    private String accountpassword;
    private int accountballance;
    private int amount;
    
    private boolean c;
    public boolean getc() {
        return c;
    }
    public void setc(boolean s) {
        this.c=s;
    }
    public String getAccountID() {
        return accountID;
    }
    public void setAccountID(String s) {
        this.accountID=s;
    }
    public String getAccountName() {
        return accountname;
    }
    public void setAccountName(String s) {
        this.accountname=s;
    }
    public String getoperatedate() {
        return operatedate;
    }
    public void setoperatedate(String s) {
        this.operatedate=s;
    }
    public int  getoperatetype() {
        return operatetype;
    }
    public void setoperatetype(int s) {
        this.operatetype=s;
    }
    public int  getaccountballance() {
        return accountballance;
    }
    public void setaccountballance(int s) {
        this.accountballance=s;
    }
    public int  getamount() {
        return amount;
    }
    public void setamount(int s) {
        this.amount=s;
    }
    public String getaccountpassword() {
        return accountpassword;
    }
    public void setaccountpassword(String s) {
        this.accountpassword=s;
    }
    public Account(String accountID1,String accountname1,String accountpassword1,int accountballance1) {
        accountID=accountID1;
        accountname=accountname1;
        accountpassword=accountpassword1;
        accountballance=accountballance1;
    }
        public Account() 
        {
        }
    }
    
    
    
    e ceshi;
    import java.util.Date;
    import java.util.Scanner;
    import java.text.SimpleDateFormat;
    class AccountManager{
    static int l=-1;static int count=0;static int m;
        private static Account []a=new Account [3];
        public AccountManager() {
            for(int i=0;i<3;i++) {
                a[i]=new Account();
            }
        a[0]= new Account("20194015","jiatan","111111",1000);
        a[1]= new Account("20194016","chenhan","111111",2000);
        a[2]= new Account("20194017","yangjialong","111111",3000);
        }
    static     void shuruzhanghao() {Scanner s=new Scanner(System.in);
            System.out.println("***************************************************************");
            System.out.println("欢迎使用中国工商银行自动柜员系统");
            System.out.println("***************************************************************");
            System.out.print("请输入您的账号:");
            
            String b=s.nextLine();
            if(b.length()<8||b.length()>8) {
                System.out.println("该卡不是工行卡.");
            }
            for(int i=0;i<3;i++) {
            count++;
            if(b.equals(a[i].getAccountID()))
            {m=i;
            l=0;
            shurumima();
            break;
            }
            }
            if(count==3) {
                System.out.println("该账号不存在");
            }
        }
    static    void shurumima() {
            Scanner s=new Scanner(System.in);
            System.out.println("***************************************************************");
            System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
            System.out.println("***************************************************************");
            System.out.print("请输入您的密码:");
            for(int i=0;i<3;i++) {
                String c=s.nextLine();
                if(i==4) {
                    System.out.println("该账号三次录入密码错误,该卡已被系统没收,请与工行及时联系处理");
                    a[m].setc(false);
                }
                if(c.compareTo(a[m].getaccountpassword())!=0) {
                    System.out.println("密码输入错误!");
                    continue;
                }
                if(c.compareTo(a[m].getaccountpassword())==0) {
                    System.out.println("***************************************************************");
                    System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
                    System.out.println("***************************************************************");
                    System.out.println("1.存款");
                    System.out.println("2.取款");
                    System.out.println("3.转账汇款");
                    System.out.println("4.修改密码");
                    System.out.println("5.查询余额");
                    System.out.println("***************************************************************");
                    int b=s.nextInt();
                    a[m].setoperatetype(b);
                    switch(b) {
                    case 1:
                        cunkuan();
                        break;
                    case 2:
                        qukuan();
                        break;
                    case 3:
                        zhuanzhang();
                        break;
                    case 4:
                        xiugai();
                        break;
                    case 5:
                        chaxun();
                        break;
                    }
                    break;
                    }
                }
            }
    static    void cunkuan() {
            Scanner s=new Scanner(System.in);
            System.out.println("***************************************************************");
            System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
            System.out.println("***************************************************************");
            System.out.print("请输入存款余额:(输入q返回账号页面)");
            String o=s.nextLine();
            char c=o.charAt(0);
            int e2=Integer.parseInt(o);
            if(c=='q') {
                shuruzhanghao();
            }
            if(e2<0) {
                System.out.println("输入金额有误");
                cunkuan();
            }
            int p=a[m].getaccountballance();
            a[m].setaccountballance(e2+p);
            System.out.println("***************************************************************");
            System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
            System.out.println("***************************************************************");
            System.out.println("当前账户余额为:"+a[m].getaccountballance()+"元");
            System.out.println("点击q键退回系统录入账号界面");
            shuruzhanghao();
        }
    static    void qukuan() {
            Scanner s=new Scanner(System.in);
            int y=0;
            System.out.println("***************************************************************");
            System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
            System.out.println("***************************************************************");
            System.out.println("                          当前账号每日可以支取2万元                   ");
            System.out.println("                             1.100元                                               ");
            System.out.println("                             2.500元                                                 ");
            System.out.println("                             3.1000元");
            System.out.println("                             4.1500元");
            System.out.println("                             5.2000元");
            System.out.println("                             6.5000元");
            System.out.println("                             7.其他金额");
            System.out.println("                             8.退款");
            System.out.println("                             9.返回                                               ");
            System.out.println("***************************************************************");
            int k=s.nextInt();
            switch(k){
            case 1:
                    if(a[m].getaccountballance()<100)
                        System.out.println("账户余额不足");
                    else
                        y=a[m].getaccountballance();
                        a[m].setaccountballance(y-100);
                        System.out.println("***************************************************************");
                        System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
                        System.out.println("***************************************************************");
                        System.out.println("当前账号取款操作100元成功");
                        System.out.println("当前账户余额为:"+a[l].getaccountballance());
                        System.out.println("***************************************************************");
                        break;
            case 2:
                if(a[m].getaccountballance()<500)
                    System.out.println("账户余额不足");
                else
                    y=a[m].getaccountballance();
                    a[m].setaccountballance(y-500);
                    System.out.println("***************************************************************");
                    System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
                    System.out.println("***************************************************************");
                    System.out.println("当前账号取款操作500元成功");
                    System.out.println("当前账户余额为:"+a[m].getaccountballance());
                    System.out.println("***************************************************************");
                    break;
            case 3:
                if(a[m].getaccountballance()<1000)
                    System.out.println("账户余额不足");
                else
                    y=a[m].getaccountballance();
                    a[m].setaccountballance(y-1000);
                    System.out.println("***************************************************************");
                    System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
                    System.out.println("***************************************************************");
                    System.out.println("当前账号取款操作1000元成功");
                    System.out.println("当前账户余额为:"+a[m].getaccountballance());
                    System.out.println("***************************************************************");
                    break;
            case 4:
                if(a[m].getaccountballance()<1500)
                    System.out.println("账户余额不足");
                else
                    y=a[m].getaccountballance();
                    a[m].setaccountballance(y-1500);
                    System.out.println("***************************************************************");
                    System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
                    System.out.println("***************************************************************");
                    System.out.println("当前账号取款操作1500元成功");
                    System.out.println("当前账户余额为:"+a[m].getaccountballance());
                    System.out.println("***************************************************************");
                    break;
            case 5:
                if(a[m].getaccountballance()<2000)
                    System.out.println("账户余额不足");
                else
                    y=a[m].getaccountballance();
                    a[m].setaccountballance(y-2000);
                    System.out.println("***************************************************************");
                    System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
                    System.out.println("***************************************************************");
                    System.out.println("当前账号取款操作2000元成功");
                    System.out.println("当前账户余额为:"+a[m].getaccountballance());
                    System.out.println("***************************************************************");
                    break;
            
        case 6:
            if(a[m].getaccountballance()<5000)
                System.out.println("账户余额不足");
            else
                y=a[m].getaccountballance();
                a[m].setaccountballance(y-5000);
                System.out.println("***************************************************************");
                System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
                System.out.println("***************************************************************");
                System.out.println("当前账号取款操作5000元成功");
                System.out.println("当前账户余额为:"+a[m].getaccountballance());
                System.out.println("***************************************************************");
                break;
        case 7:
            System.out.println("***************************************************************");
            System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
            System.out.println("***************************************************************");
            System.out.println("请输入取款金额:");
            System.out.println("***************************************************************");
            int t=s.nextInt();
            if(a[m].getaccountballance()<t)
                System.out.println("账户余额不足");
            else
                y=a[m].getaccountballance();
                a[m].setaccountballance(y-t);
                System.out.println("***************************************************************");
                System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
                System.out.println("***************************************************************");
                System.out.println("当前账号取款操作"+t+"元成功");
                System.out.println("当前账户余额为:"+a[m].getaccountballance());
                System.out.println("***************************************************************");
                break;
        case 8:
            shuruzhanghao();
            break;
        case 9:shuruzhanghao();
        break;
        }
        }
    static    void zhuanzhang()
        {Scanner s=new Scanner(System.in);
            System.out.println("***************************************************************");
            System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
            System.out.println("***************************************************************");
            System.out.print("请输入转账用户:");
            String u1=s.nextLine();
            for(int i=0;i<2;i++) {
                if(a[i].getAccountID()==u1)
            System.out.println("***************************************************************");
            System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
            System.out.println("***************************************************************");
            System.out.print("请输入转账金额:");
            int u=s.nextInt();
            if(a[m].getaccountballance()<u) {
                System.out.println("账户余额不足");
            }
            else
            {
                System.out.println("***************************************************************");
            System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
            System.out.println("***************************************************************");
            System.out.println("请确认是否向*"+a[i].getAccountID()+"转账"+u+"元");
            System.out.println("***************************************************************");
            System.out.println("单击“N”表示不确认转账,系统跳转到系统主界面;单击“Y”表示确认转账,系统跳转到转账成果界面。");
            String s2=s.next();
            if(s2.equals("N")) {
                shuruzhanghao();
            }
            if(s2.equals("Y")) {
            int g=a[i].getaccountballance();
                a[i].setaccountballance(g+u);
                int g2=a[m].getaccountballance();
                a[m].setaccountballance(g2-u);
                System.out.println("***************************************************************");
                System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
                System.out.println("***************************************************************");
                System.out.println("当前账户向*"+a[i].getAccountID()+"转账"+u+"元");
                System.out.println("***************************************************************");
                System.out.println("当前账户余额为:"+a[m].getaccountballance());
                System.out.println("***************************************************************");
            }
                System.out.println("点击q进入进入系统进行选择界面:");
                String s9=s.next();
                if(s9.equals("q")) {
                    shuruzhanghao();
                }
        }
            }
        }
    static    void xiugai() {
            Scanner s=new Scanner(System.in);
            System.out.println("***************************************************************");
            System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
            System.out.println("***************************************************************");
            System.out.println("请输入当前密码:");
            String s7=s.nextLine();
            if(s7.equals(a[m].getaccountpassword())) {
                System.out.println("请输入修改密码:");
                String s6=s.nextLine();
                System.out.println("请输入确认密码:");
                String s5=s.nextLine();
                if(s5.equals(s6)) {
                    a[m].setaccountpassword(s5);
                    System.out.println("点击q进入进入系统进行选择界面:");
                    String s9=s.nextLine();
                    if(s9.equals("q")) {
                        shuruzhanghao();
                    
                }
                else {
                    System.out.println("修改密码与确认密码不一致");
                    xiugai();
                }
            }
        }
            else {
                System.out.println("当前密码录入错误");
                xiugai();
                }
                
        }
    
    static    void chaxun()
        {Scanner s=new Scanner(System.in);
            System.out.println("***************************************************************");
            System.out.println("欢迎"+a[m].getAccountID()+"使用中国工商银行自助柜员系统");
            System.out.println("***************************************************************");
            System.out.println("当前账户余额为:"+a[m].getaccountballance());
            Date d=new Date();
            SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
            String formatDate=sdf.format(d);
            System.out.println("账户操作时间为:"+formatDate);
            System.out.println("点击q返回账号界面");
            String h=s.nextLine();
            if(h.equals("q")) {
                shuruzhanghao();
            }
        }
        public static void main(String[]args) {
            Scanner s=new Scanner(System.in);
            AccountManager a0=new AccountManager();
            shuruzhanghao();
            xiugai();
        }
    }

     

     

     

     心得:今天java开课的第一堂课进行了开学测试,主要是为了检验我们在家自学的成果如何。经过这一次的测试也是让我更加清醒的认识到了在家学习的我效果很差,在20分满分的情况下只得了12分。最后的主函数没有运行出来也是让我一脸懵。在一开始打开题目的时候,我觉得很平时练习的差不了多少,老师说有文件的内容,因为我文件的内容不会,如果当堂再学的话,把时间全用光可能也学不会,所以我就用了数组去代替文件调用数据内容。我一开始以为ATM是账户一个人的信息就够了,但是我写到转账的时候才意识到应该使用数组的内容。这时候我大脑想着要是现在加入数组会不会导致大部分 的内容都不正确。但是我想了想,无非就是加了个中括号而已,所以从头到尾一直使用的单个变量。在最后提交代码之后我和正确的代码比对了一下,发现我的代码行数繁多,老师也说我代码乱。我觉得也是,应该让代码看起来更好看一点,这样以后工作了别人看起来才方便,毕竟以后是小组工作不是一个人了。代码繁多的主要原因是那些界面System输出我都是复制粘贴的,应该做一个专门的函数,需要的时候调用就好了,这样既节省了行数也节省了我的时间。还有就是每一个函数中的我用条件语句if 的时候我想让String类型=一个数据我直接用了==,还有我让一个字符=一个字符的时候我也是用了==,我看正确的时候我发现别人用了equals.(),这样才是正确的,因为这个地方虽然程序没有报错但是运行出来是不正确的。当我输出一个数组内的数据的时候他总是和我预想的不一样,包括一些数据需要静态定义才可以进行调用。还有一个很严重的问题是,主函数需要在类中进行才可以,当分成不同的类的时候使用eclipse需要在左侧建立不同的类,而我写的时候我在一个类中定义了两个类,这样是不可以的。在对数组内的数据进行赋值的时候我用了函数进行调用,想着在函数里面对account类进行赋值,但我不知道把函数应该放在什么位置上,而且这样的话需要数组内几个数据,方法就需要几个。最后才意识到用构造函数的概念,需要两个构造函数,一个带有参数,对内容进行赋值,这样就很方便了,而且只需要一行代码就可以解决问题。我在各个功能之间把方法放在了方法之中,这样好像有点麻烦,虽然在主函数的时候只需要调用一个就够了,但是在方法之中需要很长的一段代码包括很多的判定,判定里面还有判定,这就加大了我大逻辑能力的要求。很容易写着写着就不知道写到哪了,所以还是应该一点点一部分的写,这样也可以让看的人明白。前几个方法还好一点,我也知道思路应该如何去写,但是到了最后一个的查询,我发现他不仅要有时间,时间这一方面我还不会,我只能去查。而且需要知道在操作的时候的时间而不是当前的时间当时操作的内容是什么,流水资金是多少。我看了看account类中只有一个int类型的流水资金,那我如何才能用一个数据包括这么多的内容呢,我思考了一下发现没有任何的思路,当时就把页面大体的写了一些就打算放弃最后一个方法了。现在我也没想到应该如何去写一个这样的方法,可能是需要文件操作吧,我只用了数组所以可能不能对其进行合适的操作。所以文件操作对于编程来说还是非常重要的,以后还是要把这部分的内容补回来,并且做到精通,这样 才能适应以后职场的需求和客户的要求。

  • 相关阅读:
    第三十三天 客户机和tcp多个客户端通信
    第三十二天黏包问题及解决方法:
    第三十一天 udp通信和黏包
    第三十天网路的基础
    第二十九天日志和config模块:
    Linux系统开机显示BusyBox v1.22.1 built-in shell(ash) 解决方法
    MTK迁移Oracle单库
    Ubuntu14.04安装mysql
    Ubuntu14.04下tomcat的安装
    Thinking in Java Chapter4 Exercise10 吸血鬼数字
  • 原文地址:https://www.cnblogs.com/feng747/p/13715628.html
Copyright © 2020-2023  润新知