ATM开学测试(未完成)
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开学测试(未完成)的更多相关文章
- Java开学测试
这次开学测试要求做一个信息系统,该系统完成学生成绩录入,修改,计算学分积点和查询学生成绩的简单功能. 下面是我写的代码 //信1805-3班 20183641 赵树琪 package test; im ...
- JAVA 开学测试
package StudentScore; public class ScoreInformation { String stunumber; //学号 String name; //姓名 doubl ...
- Java开学测试感想
开学第一堂课就是测试,测试暑假的自学成果,老师说试卷适当提高了难度,所以允许查书和使用网络查询,经过近三个钟头的努力奋斗和痛苦挣扎,我只完成了一小部分的代码,只有简单的set()get()函数,以及简 ...
- 软件工程课开学测试——根据已有的CSS模板资源,搭建整个系统
日期:2019.2.28 博客期:038 星期四 今天的测试得到了9.5分,将将及格的程度吧!本次程序完成的很不成功! <%@ page language="java" co ...
- Java课程2019年3月开学测试
一.登录界面 模板的验证方式已经写在了function里面,我们只需要在提交的过程中进行验证. 我们这里需要注意到的是在login文件夹中,有一个randcode的验证码生成文件,打开代码我们可以看到 ...
- Java开学测试源代码
package sample; import java.io.IOException;import java.io.Serializable;import java.util.Scanner;impo ...
- Java开学测试-学生成绩管理系统
题目: 1.定义 ScoreInformation 类,其中包括七个私有变量(stunumber, name, mathematicsscore, englishiscore,networkscore ...
- java开学考试有感以及源码
一.感想 Java开学测试有感 九月二十号,王老师给我们上的第一节java课,测试. 说实话,不能说是十分有自信,但还好,直到看见了开学测试的题目,之前因为已经做过了王老师发的16级的题目,所以当时还 ...
- 【转】如何测试CTS4.0 -- 不错
原文网址:http://blog.csdn.net/subsist/article/details/7209341/ CTS4.0测试步骤 V1.2 (更新到CTS4.0 R3) 第一:平台准 ...
随机推荐
- 对Python源码加密及反编译前后对比
关于python的加密 目前软件开发商对 Python 加密时可能会有两种形式,一种是对python转成的exe进行 保护,另一种是直接对.py或者.pyc文件进行保护,下面将列举两种形式的保护流程. ...
- SpringBoot 项目健康检查与监控(转)
前言 You build it,You run it, 当我们编写的项目上线后,为了能第一时间知晓该项目是否出现问题,常常对项目进行健康检查及一些指标进行监控.Spring Boot-Actuator ...
- Java写xml文件
import java.io.FileOutputStream; import org.dom4j.Document; import org.dom4j.DocumentHelper; import ...
- jenkins windows slave 报错ERROR: Error cloning remote repo 'origin'
在slave上是git clone ssh是可以成功的,但是jenkins调用slave节点就报如下错误: ERROR: Error cloning remote repo 'origin' huds ...
- SDWebImage代码赏析
过NSOperationQueue来控制 为了保护变量,使用大量了sychronized 读的时候使用了dispatch_sync dispatch_sync(sself.barrierQueue, ...
- vue滚动事件销毁,填坑
eg:富文本的头部固定,当滚轮大于200时(举例)固定在浏览器头部,距离大于富文本时,头部消失 效果: 在富文本下面加一个空div 这么写: mounted() { $(window).scroll( ...
- ubuntu 安装/卸载nginx及常用命令
安装命令 sudo apt-get update #更新apt sudo apt-get install nginx #安装nginx 启动/重启/停止命令 一. /etc/init.d/nginx ...
- LeetCode14.最长公共前缀
编写一个函数来查找字符串数组中的最长公共前缀. 如果不存在公共前缀,返回空字符串 "". 示例 1: 输入: ["flower","flow" ...
- Python数据可视化-seaborn
详细介绍可以看seaborn官方API和example galler. 1 set_style( ) set( ) set_style( )是用来设置主题的,Seaborn有五个预设好的主题: d ...
- Spark学习之路 (二十八)分布式图计算系统
一.引言 在了解GraphX之前,需要先了解关于通用的分布式图计算框架的两个常见问题:图存储模式和图计算模式. 二.图存储模式 巨型图的存储总体上有边分割和点分割两种存储方式.2013年,GraphL ...