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) 第一:平台准 ...
随机推荐
- JavaScript基础学习2
/* 1.把函数作为参数.匿名函数作为参数传递到函数 */ function dogEat(food) { console.log("dog eat " + food); } fu ...
- golang 中的 sizeof 以及 golang中的 union
golang 中的 sizeof: 1: int(unsafe.Sizeof(uint32(0))) 2: int(reflect.TypeOf(uint32(0)).Size()) golang中的 ...
- php合并数组并保留键值的方法
答案:使用 + 连接两个数组,替换array_merge()函数. php合并数组,一般会使用array_merge方法. array_merge — 合并一个或多个数组 array array_me ...
- linux iscsi挂载与卸载
iscsiadm -m discovery -t sendtargets -p 192.168.4.245:3260 #扫描ISCSI Target 列出所有LUN iscsiadm -m node ...
- git 冲突解决办法
1. Pull is not possible because you have unmerged files. 症状:pull的时候 $ git pull Pull is not possible ...
- python获取当前,昨天,明天时间
import datetime nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')#现在 pastTimeMinutes = ...
- 从零开始一起学习SLAM | SLAM有什么用?
SLAM是 Simultaneous Localization And Mapping的 英文首字母组合,一般翻译为:同时定位与建图.同时定位与地图构建. 「同时定位与地图构建」这几个词,乍一听起来非 ...
- node.js初识03
node中的url var http = require("http"); var url = require("url"); var server = htt ...
- python爬虫-基础入门-爬取整个网站《3》
python爬虫-基础入门-爬取整个网站<3> 描述: 前两章粗略的讲述了python2.python3爬取整个网站,这章节简单的记录一下python2.python3的区别 python ...
- animator 新动画
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Animator ...