package ATM_design;
//信1705-2 20173456 张浩
import java.util.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; public class Account { public static List<Account> accountlist=new LinkedList<Account>();
String accountID;
String accountname;
String operatedate;
int operatetype;
String accountpassword;
int accountbalance;
int amount;
public Account() {};
public Account(String accountID,String accountname,String operatedate,int operatetype,String accountpassword,int accountbalance) {
this.accountID=accountID;
this.accountname=accountname;
this.operatedate=operatedate;
this.operatetype=operatetype;
this.accountpassword=accountpassword;
this.accountbalance=accountbalance;
}
public Account(String accountID,String accountname,String accountpassword,int accountbalance) {
this.accountID=accountID;
this.accountname=accountname;
this.accountpassword=accountpassword;
this.accountbalance=accountbalance;
}
public Account(String accountID,String accountname,String operatedate,int operatetype,int amount) {
this.accountID=accountID;
this.accountname=accountname;
this.operatedate=operatedate;
this.operatetype=operatetype;
this.amount=amount;
}
public String get_accountID() {
return accountID;
}
public String get_accountname() {
return accountname;
}
public String get_operatedate() {
return operatedate;
}
public int get_operatetype() {
return operatetype;
}
public String get_accountpassword() {
return accountpassword;
}
public int get_accountbalance() {
return accountbalance;
}
public int get_amount() {
return amount;
}
public void set_accountID(String accountID) {
this.accountID=accountID;
}
public void set_accountname(String accountname) {
this.accountname=accountname;
}
public void set_operatedate(String operatedate) {
this.operatedate=operatedate;
}
public void set_operatetype(int type) {
this.operatetype=type;
}
public void set_accountpassword(String password) {
this.accountpassword=password;
}
public void set_accountbalance(int balance) {
this.accountbalance=balance;
}
public void set_amount(int amount) {
this.amount=amount;
}
public static void addaccount (String accountID,String accountname,String accountpassword,int accountbalance) {
accountlist.add(new Account(accountID,accountname,accountpassword,accountbalance));
}
public static void file_in() {
File file0 = new File("F:/eclipse/ATM", "accountinformation.txt");
addaccount("20173450","zhangqiang","000001",900);//创建第一个账户并放入list中
addaccount("20173451","zhanghao","000002",1000);//创建第二个账户
addaccount("20173452","sunyang","000003",700);//创建第三个账户
addaccount("20173453","lihao","000004",1200);//创建第四个账户
addaccount("20173454","liulei","000005",8500);//创建第五个账户//创建文件对象
try {
if (!file0.exists()) { //如果文件不存在则新建文件
file0.createNewFile(); }
FileOutputStream output = new FileOutputStream(file0);
for(int j=0;j<accountlist.size();j++) {
byte[] bytes0 =accountlist.get(j).accountID.getBytes();
byte[] bytes1 =accountlist.get(j).accountname.getBytes();
byte[] bytes2 =accountlist.get(j).accountpassword.getBytes();
output.write(bytes0);
output.write(bytes1);
output.write(bytes2);
output.write(accountlist.get(j).accountbalance);
}
output.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} /*public static void file_out() {
try {
FileInputStream input = new FileInputStream(file0);
for(int j=0;j<accountlist.size();j++) {
byte[] bytes0 =accountlist.get(j).accountID.getBytes();
byte[] bytes1 =accountlist.get(j).accountname.getBytes();
byte[] bytes2 =accountlist.get(j).accountpassword.getBytes();
input.read input.close();
} }catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}*/
} package ATM_design; import java.util.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
public class AccountMannager {
    
    public static void main(String[] args) {
        String ID;
        System.out.println("***************************************************************");
        System.out.println("             欢迎使用中国工商银行自动柜员系统!");
        System.out.println("****************************************************************");
        Account a = new Account();
        a.file_in();//提前存入5组数据
        boolean temp=true;
        while(temp==true) {
            System.out.print("请输入您的账号:");
            Scanner number=new Scanner(System.in);
             ID=number.nextLine();
                if(ID.length()!=8) {
                System.out.println("您输入的账号不是工商行卡号!请重新输入");
            }
            
                if(ID.length()==8) {
                for(int j=0;j<a.accountlist.size();j++) {
                    if(ID==a.accountlist.get(j).get_accountID()) {
                        System.out.println("已查询到您的账户");
                        System.out.println("***************************************************************");
                        System.out.println("欢迎"+a.accountlist.get(j).get_accountname()+"使用中国工商银行自助柜员系统");
                        System.out.println("请输入密码:");
                        int i=0;
                         while(i<2)
                         {
                            
                                Scanner password=new Scanner(System.in);
                                 String pw=password.nextLine();
                        if(pw!=a.accountlist.get(j).get_accountpassword())
                        {
                            i++;
                            System.out.println("密码输入错误!");                       
                            if(i==2)
                            {
                                System.out.println("该账号三次录入密码错误,该卡已被系统没收,请与工行及时联系处理");
                                temp=false;
                                break;    
                            }
                        }
                        else {
                        System.out.println("***************************************************************");
                        System.out.println("欢迎"+a.accountlist.get(j).get_accountname()+"使用中国工商银行自助柜员系统");
                        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("请输入您要进行的操作序号:");
                        String op;
                        Scanner operator=new Scanner(System.in);
                        op=operator.nextLine();
                        switch(op) {
                        case "1":
                            System.out.println("***************************************************************");
                            System.out.println("欢迎"+a.accountlist.get(j).get_accountname()+"使用中国工商银行自助柜员系统");
                            System.out.println("***************************************************************");
                            System.out.println("请输入您的存款金额:");
                            int save_money;
                            Scanner save=new Scanner(System.in);
                            save_money=save.nextInt();
                            if(save_money>0) {
                                System.out.println("***************************************************************");
                                System.out.println("欢迎"+a.accountlist.get(j).get_accountname()+"使用中国工商银行自助柜员系统");
                                System.out.println("***************************************************************");
                                System.out.println("          当前账户存款成功!");
                                System.out.println("当前账户余额为:"+(a.accountlist.get(j).get_accountbalance()+save_money)+"元");
                                System.out.println("***************************************************************");
                                System.out.println("若要进行其他操作需要重新录入密码:");
                                break;
                            }
                            else {
                                System.out.println("您输入的金额有误,请输入正整数!");
                                System.out.println("请再次进行操作");
                                continue;
                            }
                        case "2":
                            System.out.println("***************************************************************");
                            System.out.println("欢迎"+a.accountlist.get(j).get_accountname()+"使用中国工商银行自助柜员系统");
                            System.out.println("***************************************************************");
                            System.out.println("              当前账户每日可支取两万元。");
                            System.out.println("              1、100元\n2、500元\n3、1000元\n4、1500元\n5、2000元\n6、5000元\n7、其他金额\n8、退卡\n9、返回");
                            Scanner chioce=new Scanner(System.in);
                            int cho=chioce.nextInt();
                            switch(cho) {
                            case 1:
                                if(a.accountlist.get(j).get_accountbalance()<100) {
                                    System.out.println("余额不足请重新选择:");
                                    Scanner cho;
                                }
                            }
                        }
                        }
                            
                          }
                        if(temp==false)
                            break;
                    }
                    
                }
            }
        }
  代码只写到了取款,而且对于文件的操作处理的不是很好,感觉自己能力有点跟不上老师的出题节奏啊~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~以后会继续努力~~~~~~~~~~~~~~~~~~~~~!!!!!!!!!

ATM开学测试(未完成)的更多相关文章

  1. Java开学测试

    这次开学测试要求做一个信息系统,该系统完成学生成绩录入,修改,计算学分积点和查询学生成绩的简单功能. 下面是我写的代码 //信1805-3班 20183641 赵树琪 package test; im ...

  2. JAVA 开学测试

    package StudentScore; public class ScoreInformation { String stunumber; //学号 String name; //姓名 doubl ...

  3. Java开学测试感想

    开学第一堂课就是测试,测试暑假的自学成果,老师说试卷适当提高了难度,所以允许查书和使用网络查询,经过近三个钟头的努力奋斗和痛苦挣扎,我只完成了一小部分的代码,只有简单的set()get()函数,以及简 ...

  4. 软件工程课开学测试——根据已有的CSS模板资源,搭建整个系统

    日期:2019.2.28 博客期:038 星期四 今天的测试得到了9.5分,将将及格的程度吧!本次程序完成的很不成功! <%@ page language="java" co ...

  5. Java课程2019年3月开学测试

    一.登录界面 模板的验证方式已经写在了function里面,我们只需要在提交的过程中进行验证. 我们这里需要注意到的是在login文件夹中,有一个randcode的验证码生成文件,打开代码我们可以看到 ...

  6. Java开学测试源代码

    package sample; import java.io.IOException;import java.io.Serializable;import java.util.Scanner;impo ...

  7. Java开学测试-学生成绩管理系统

    题目: 1.定义 ScoreInformation 类,其中包括七个私有变量(stunumber, name, mathematicsscore, englishiscore,networkscore ...

  8. java开学考试有感以及源码

    一.感想 Java开学测试有感 九月二十号,王老师给我们上的第一节java课,测试. 说实话,不能说是十分有自信,但还好,直到看见了开学测试的题目,之前因为已经做过了王老师发的16级的题目,所以当时还 ...

  9. 【转】如何测试CTS4.0 -- 不错

    原文网址:http://blog.csdn.net/subsist/article/details/7209341/ CTS4.0测试步骤 V1.2 (更新到CTS4.0 R3)     第一:平台准 ...

随机推荐

  1. lua加载函数require和dofile

    lua加载函数require和dofile Lua提供高级的require函数来加载运行库.粗略的说require和dofile完成同样的功能但有两点不同: 1. require会搜索目录加载文件; ...

  2. ssh 的认证原理

    SSH:Secure Shell,是一种网络安全协议,主要用于登录远程计算机的加密过程. 登录方式主要有两种: 1.基于用户密码的登录方式:   加密原理:   当服务器知道用户请求登录时,服务器会把 ...

  3. 【LeetCode每天一题】Find First and Last Position of Element in Sorted Array(找到排序数组中指定元素的开始和结束下标)

    Given an array of integers nums sorted in ascending order, find the starting and ending position of ...

  4. 【LeetCode每天一题】Palindrome Number( 回文数字)

    Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same back ...

  5. [LeetCode] 504. Base 7_Easy tag: Math

    Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202&q ...

  6. statement对象与sql语句(新手)

    本篇介绍读上篇代码中的疑惑点 实现简单网页上对数据内容进行增删改查,需要用到三个部分:jsp网页前端部分+java后台程序+数据库表 一.创建一个Statement (用于在已经建立数据库连接的基础上 ...

  7. react 写一个贪吃蛇

    示例: 全部代码如下: snake.jsx import React, { Component } from 'react'; import PropTypes from 'prop-types'; ...

  8. cocos2d-x JS 开启远程代码调试

    为了方便服务端与测试部门的工作需要,把客户端的写的程序可以在其他电脑上运行,方便他人工作与测试. 下面是cocos2d-x JS WebStorm 的设置方法.

  9. 设置sqlplus不显示除查询结果外的信息

    背景:客户提出一个需求,写SQL脚本的时候,内容是拼接的,如何将这个拼接SQL执行的结果取出来调用执行呢? 我想到的方案是先把结果取出来,存为一个中间文件,再调用该文件即可. 知识点:如何将sqlpl ...

  10. LeetCode168.Excel表列名称

    给定一个正整数,返回它在 Excel 表中相对应的列名称. 例如, 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> ...