• java测试感受


            这个星期四下午来了一次Java考试,用来测试在暑假自学Java的学习情况,不得不说这次考试十分的成功,把我对这学期的学习信心打击的很难受,我也知道这是我应得的教训,我也对我的专业水平有了很深刻的了解了,自己会什么,不会什么,在我心里都有了明确的了解,更说明了我在暑假期间所学到的那些东西,根本不足以我让我个人完成一个完整的项目,在这次考试中,我也只写了最简单的前面的部分,剩下的难点我都不会,对于这次考试,我个人感受到的只有绝望,可能也有完全会做的人,对于他来说可能写代码是一件令人能感到愉悦的事,对我来说似乎有一点难受,通过这次考试,让我知道了自己在什么水平上,以现在的水平能否在将来在IT行业中占有一席之地,在我的心里也都有了十分明确答案’,那种无力感和焦急感能让我记住很长时间,对我来说印象深刻,可能现在还没吃到因为专业水平不够的亏,但是照这样下去也就是早晚的事,对于我来说这个试卷有点难了,我承认我这次完成这个完整的代码其中是有抄袭的,不过同时也并不是抄完就完事了,我也会学习里边的结构、用法什么,但是文件的那里有点难理解,不是很明白,我个人觉的抄没什么,如果能在过程中能把他变成自己的东西就是值得的,也是一种学习的方式,肯定不适合长期这么做,如果能在以后的学习生活中不在出现这种情况,那么就是很大的进步。我也希望自己能够在专业水平上有所提高,如果可以自己独立完成,谁愿意用这种方式完成作业,所以我也买了几本书用来再去学习java的相关知识,用来提高自己的水平,让自己的有更好的水平是每个人都希望的,谁都不愿意在大学中白白浪费了这几年的时间,浪费提高自己水平的大好时光,也想完成自己在入学之前对自己的期许,不辜负任何人,这谁都想做到。

           在考试结束的时候,给我测试的是一个大四的老学长,我和他聊了几句,他说他没有去那天的招聘会,他说那里给的工资太低了,他就随意的带过去了,但我在上课的时候,看见了不少去招聘的学生,每个人都穿上西装,看起来很有气势的样子,但是我一联想到他说的薪酬不高,大四的学长又说他不去,在感叹时光流逝之快的同时,我也感觉在大学接近四年的学习生活中,即使是同班同学甚至是同宿舍的那几个人之中,都会在专业水准上分出个三六九等,水平高的自然眼界也就高了,工资给的低根本不用去浪费时间,而水平不够的只能在这些给的工资水平低的公司中选择,我似乎感觉到了他们的无奈,但是却无可奈何,后悔估计也没用了,估计如果我在以后的学习生活中再浑浑噩噩的过下去,没准也和现在去招聘的学生一样,虽然说三百六十五行,行行出状元,可我已经进入了这个行列,估计以后都不会再改了,所以这只能逼着自己去学习。

    Account.java

    /*

    信1705-3 2017541 伊帅

    */
    package ATM;

    public class Account {
     private String accountID;//账号
     
     private String accountname;//名称
     
     private String operatedate;//日期
     
     private int operatetype;//类型
     
     private String accountpassword;//密码
     
     private int accountbalance;//余额
     
     private int amount;//操作流水的金额
     public Account(String accountID, String accountname, String operatedate, int operatetype,

       String accountpassword,int accountbalance,int amount) {

      this.accountID = accountID;

      this.accountname = accountname;

      this.operatedate = operatedate;

      this.operatetype = operatetype;

      this.accountpassword = accountpassword;
      
      this.accountbalance = accountbalance;
      
      this.amount = amount;}
     
     public String getAccountID() {
      return accountID;
     }
     public void setAccountID(String accountID) {
      this.accountID = accountID;
     }

     public String getAccountName() {
      return accountname;
     }
     public void setAccountName (String accountName) {
      this.accountname = accountName;
     }
     
     public String getOperatedate() {
      return operatedate;
     }
     public void setOperatedate(String Operatedate) {
      this.operatedate = Operatedate;
     }
     
     public int getOperatetype() {
      return operatetype;
     }
     public void setOperatetype(int Operatetype) {
      this.operatetype = Operatetype;
     }
     
     public String getAccountpassword() {
      return accountpassword;
     }
     public void setAccountpassword(String accountpassword) {
      this.accountpassword = accountpassword;
     }
     
     public int getAccountbalance() {
      return accountbalance;
     }
     public void setAccountbalance(int accountbalance) {
      this.accountbalance = accountbalance;
     }
     
     public int getAmount() {
      return amount;
     }
     public void setAmount(int amount) {
      this.amount = amount;
     }
    }

    AccountManager.java

    package ATMOP;
    import java.util.*;
    public class AccountManager {
     @SuppressWarnings({ "resource", "unused" })//(“unused”)未使用的变量  (“resource”)有泛型未指定类型
     public static void main(String[] args)  throws NumberErrorException {
      // TODO Auto-generated method stub
      Scanner in=new Scanner(System.in);
            PATM atm=new ATM();
            NumberErrorException nee=new NumberErrorException("输入非法!");
            NotHundredTimesException nhte=new NotHundredTimesException("不是一百的整数倍!");
            PasswordErrorException pee=new PasswordErrorException("输入错误的密码超过三次!");
            int passwordErrorTimes=0;
            int choose=-1,number=0,x=0;
            String num="";
            String pw="";
            next:while(true){
             System.out.println("******************************");
                System.out.println("   欢迎使用中国工商银行自助柜员系统       ");
                System.out.println("******************************");
                System.out.println("请输入您的账号:");
                int kk=-1;
                String c=in.next();
                if(whetherNum(c))
                    kk=Integer.parseInt(c);
                if(kk==0) break;
                else if(kk!=1){
                    System.out.println("输入错误!");
                    continue;
                }
                System.out.println("************************************************");
                System.out.println("  欢迎***使用中国工商银行自助柜员系统  ");
                System.out.println("************************************************");
                System.out.println("请输入您的密码:");
                pw=in.next();
                if(atm.ifPass(pw)){
                    while(true){
                        showFace();
                        String cc=in.next();
                        if(whetherNum(cc))
                            choose=Integer.parseInt(cc);
                        switch(choose){
                        case 1:
                         System.out.println("******************************************");
                            System.out.println("  欢迎***使用中国工商银行自助柜员系统  ");
                            System.out.println("*******************************************");
                            System.out.println("输入存款金额:");
                            while(true){
                                try{
                                    num=in.next(); 
                                    if(!whetherNum(num))
                                        throw nee;
                                    else if((x=Integer.parseInt(num)%100)!=0)
                                        throw nhte;
                                    else
                                        break;
                                }
                                catch(NumberErrorException e){
                                    System.out.println("输入正确的数字!");
                                }
                                catch(NotHundredTimesException e){
                                    System.out.println("录入错误,请输入合法的整数(100的整数倍)!");
                                }
                            }
                            number=Integer.parseInt(num); 
                            atm.save(number);
                            System.out.println("****************************************************");
                            System.out.println("  欢迎***使用中国工商银行自助柜员系统  ");
                            System.out.println("****************************************************");
                            System.out.println("当前账户存款操作成功。");
                            System.out.println("当前账户余额为:"+atm.getRest()+"元");
                            break;
                        case 2:
                         System.out.println("*****************************************************");
                         System.out.println("  欢迎***使用中国工商银行自助柜员系统  ");
                            System.out.println("*****************************************************");
                            System.out.println("当前用户每日可以支取2万元。");
                            System.out.println("请选择:");
                            int a[]={100,500,1000,1500,2000,5000};
                            for(int i=0;i<a.length;i++)
                                System.out.println((i+1)+"."+a[i]+"元");
                            System.out.println("7.其他金额");
                            String bb="";
                            int ch=-1;
                            bb=in.next();
                            if(whetherNum(bb)){
                                ch=Integer.parseInt(bb);
                            }
                            if(ch>=1&&ch<=6){
                                if(atm.withdraw(a[ch-1]))
                                {
                                System.out.println("*************************************************");
                                System.out.println("  欢迎***使用中国工商银行自助柜员系统  ");
                                System.out.println("*************************************************");
                                System.out.println("当前账户取款操作成功!     ");
                                }
                                else
                                    System.out.println("账户余额不足!");
                            }
                            else if(ch==7){
                             System.out.println("*****************************************************");
                                System.out.println("  欢迎***使用中国工商银行自助柜员系统  ");
                                System.out.println("***************************************************");
                                System.out.println("请输入取款金额:");
                                while(true){
                                    try{
                                        num=in.next();
                                        if(!whetherNum(num))
                                            throw nee;
                                        else if((x=Integer.parseInt(num)%100)!=0)
                                            throw nhte;
                                        else
                                            break;
                                    }
                                    catch(NumberErrorException e){
                                        System.out.println("输入正确的数字!");
                                    }
                                    catch(NotHundredTimesException e){
                                        System.out.println("录入错误,请输入合法的整数(100的整数倍)!");
                                    }
                                }
                                number=Integer.parseInt(num);
                                if(atm.withdraw(number))
                                    System.out.println("取款成功!");
                                else 
                                    System.out.println("余额不足!");
                            }
                            else 
                                System.out.println("输入有误!");
                            System.out.println("当前余额:"+atm.getRest()+"元");
                            break;
                        case 3:
                         System.out.println("******************************************************");
                            System.out.println("  欢迎***使用中国工商银行自助柜员系统  ");
                            System.out.println("*******************************************************");
                            System.out.println("请输入转账账户:");
                            String s=in.next();
                            System.out.println("***************************************************");
                            System.out.println("  欢迎***使用中国工商银行自助柜员系统  ");
                            System.out.println("***************************************************");
                            System.out.println("请输入转账金额:");
                            while(true){
                                try{
                                    num=in.next();
                                    if(!whetherNum(num))
                                        throw nee;
                                    else if((x=Integer.parseInt(num)%100)!=0)
                                        throw nhte;
                                    else
                                        break;
                                }
                                catch(NumberErrorException e){
                                    System.out.println("输入正确的数字!");
                                }
                                catch(NotHundredTimesException e){
                                    System.out.println("录入错误,请输入合法的整数(100的整数倍)!");
                                }
                            }
                            number=Integer.parseInt(num);
                            if(atm.transfer(s, number))
                                System.out.println("转账成功!");
                            else
                                System.out.println("转账失败!");
                            System.out.println("当前余额:"+atm.getRest()+"元");
                            break;
                        case 4:
                         System.out.println("输入当前密码:");
                         String M=in.next();
                            System.out.println("输入修改密码:");
                            String p=in.next();
                            if(p.length()==6&&whetherNum(p))
                                atm.setPassword(p);
                            else{
                                System.out.println("不是六位或者不是数字!");
                            }
                            break;
                        case 5:
                            System.out.println("当前余额:"+atm.getRest()+"元");
                            break;
                        default:
                            continue next;
                        }
                    }
                }
                else{
                    System.out.println("密码错误!");
                    try{
                        passwordErrorTimes++;
                        if(passwordErrorTimes>3)
                            throw pee;
                    }
                    catch(PasswordErrorException e){
                        System.out.println(e.getMessage()+"账户暂时冻结!");
                        return ;
                    }
                }

         }
     }
      //显示菜单
        public static void showFace(){
         System.out.println("**********************************************************");
            System.out.println("  欢迎***使用中国工商银行自助柜员系统  ");
            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("    6.退卡:");
            System.out.println("*************************************************");
            System.out.println("请选择:");
        }
        //判断字符串是否为整数(0-999999)
        public static boolean whetherNum(String s){
            boolean flag=true;
            if(s.length()>=7)
                return false;
            char arr[]=s.toCharArray();
            for(int i=0;i<s.length();i++){    
                if(arr[i]<'0'||arr[i]>'9')
                    flag=false;
            }
            return flag;
        }
    }

    class PersonalAccount{
        private String passWord="123456";//密码
        @SuppressWarnings("unused")
        private String number;//银行卡号
        private int money=0;
        public int getMoney(){return money;}//余额
        public void setPw(String s){passWord=s;}//设置密码
        public void addMoney(int x){money+=x;}//加钱
        public void minusMoney(int x){money-=x;}//减钱
        public boolean whetherPwTrue(String s){//密码是否正确
            if(s.equals(passWord))
                return true;
            else return false;
        }
    }
    //abstract修饰类,会使这个类成为一个抽象类
    abstract class PATM{
        public abstract boolean withdraw(int x);//取款
        public abstract void save(int x);//存款
        public abstract boolean transfer(String s,int x);//转账
        public abstract boolean ifPass(String s);//判断输入的密码是否正确
        public abstract int getRest();//查询余额
        public abstract void setPassword(String s);//设置密码
    }
    class ATM extends PATM{
        private String numbers[]={"1234567891000000","11112222333344445"};//已有的账户卡号
        private PersonalAccount account=new PersonalAccount();
        public boolean withdraw(int x) {
            if(x>account.getMoney())
                return false;
            else{
                account.minusMoney(x);
                return true;
            }
        }
        public void save(int x) {
            account.addMoney(x);
        }
        public boolean transfer(String s, int x) {
            //转账
            //先判断转到账户号是否存在
            //再判断余额是否足够
            boolean flag=false;
            for(int i=0;i<numbers.length;i++)//比较s是否和t相等,返回一个boolean类型的值(即false或者true)
                if(s.equals(numbers[i])) flag=true;//equals()方法在Object定义中是与==相等.就是比较2个对象引用是否相等
            if(x>account.getMoney()) flag=false;
            if(x<=account.getMoney()&&flag) account.minusMoney(x);;
            return flag;
        }
        public boolean ifPass(String s) {
            return account.whetherPwTrue(s);
        }
        public int getRest() {
            return account.getMoney();
        }
        public void setPassword(String s) {
            account.setPw(s);        
        }
    }
    @SuppressWarnings("serial")
    class NumberErrorException extends Exception{
        public NumberErrorException(String msg){
            super(msg);
        }
    }
    @SuppressWarnings("serial")
    class PasswordErrorException extends Exception{
        public PasswordErrorException(String msg){
            super(msg);
        }
    }
    @SuppressWarnings("serial")
    class NotHundredTimesException extends Exception{
        public NotHundredTimesException(String msg){
            super(msg);
        }
    }

  • 相关阅读:
    java入门第一篇:h5和CSS的基础学习及思考。
    Dubbo-入门到精通(一)
    跳表(skipList)的原理和java实现
    Springboot
    zookeeper 常用命令及znode简介
    Zookeeper 实现分布式锁服务
    Golang 基础
    ipython notebook 如何修改一开始打开的文件夹路径
    Loadrunner11配置Jdk,以及是否成功配置验证
    Redis学习
  • 原文地址:https://www.cnblogs.com/yishaui/p/9696419.html
Copyright © 2020-2023  润新知