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) 第一:平台准 ...
随机推荐
- UE4程序及资源加密保护方案
UnrealEngine4外壳加密 . Virbox Protector 解决代码反汇编和反dump代码,解决软件盗版与算法抄袭. 虚幻引擎4是由游戏开发者为开发游戏而制作的.完整的游戏开发工具套件. ...
- HBase 数据迁移方案介绍 (转载)
原文地址:https://www.cnblogs.com/ballwql/p/hbase_data_transfer.html 一.前言 HBase数据迁移是很常见的操作,目前业界主要的迁移方式主要分 ...
- centos7下git服务器端搭建
git的安装: yum 源仓库里的 Git 版本更新不及时,最新版本的 Git 是 1.8.3.1,但是官方最新版本已经到了 2.9.2.想要安装最新版本的的 Git,只能下载源码进行安装. 1. 查 ...
- ansible-playbook 快速入门
管理用户密码: --- - hosts: test tasks: - name: changed password shell: echo root:123456 | chpasswd remote_ ...
- 2018-2019-1 20189221 《Linux内核原理与分析》第七周作业
2018-2019-1 20189221 <Linux内核原理与分析>第七周作业 实验六 分析Linux内核创建一个新进程的过程 代码分析 task_struct: struct task ...
- 截取字符串后几位用 length
- 32-Python3 MySQL(mysql-connector)
32-Python3 MySQL(mysql-connector) ''' 创建数据库连接 ''' import pymysql mydb = pymysql.connect( host = '127 ...
- sqli-labs(十二)(union以及select的过滤)
第二十七关: 这关禁用了空格和select,空格还是可以使用()代替,select发现可以大小写绕过 输入?id=1'||extractvalue(1,concat(0x5c,(selEct(grou ...
- python 定义函数 两个文件调用函数
在def_function.py文件里面写 #coding=utf-8 #定义函数 def hello(): print "hello world" 在test.py里面调用 #c ...
- VMware vSphere
在进行操作vSphere产品之前,就曾经对它进行过一个简单了解:[运维]VMware vSphere简单了解,现在再回头看,发现了解的真的是太简单了.经过前一段时间学习之后,对它又有了新的感悟,再来谈 ...