关键词:
//基本功能已经完善,文件读取没有问题,文件重写尚未完成。
Account类
public class Account { //初始化参数 private String accountID; private String accountname; private String operatedate; private int operatetype; private String accountpassword; private int accountbalance=0; private int amount; //构造读取和设置变量信息的方法 public void setAccountID(String accountID) {this.accountID=accountID;} public String getAccountID() {return accountID;} public void setAccountname(String accountname) {this.accountname=accountname;} public String getAccountname() {return accountname;} public void setOperatedate(String operatedate) {this.operatedate=operatedate;} public String getOperatedate() {return operatedate;} public void setOperatetype(int operatetype){this.operatetype=operatetype;} public int getOperatetype() {return operatetype;} public void setAccountpassword(String accountpassword) {this.accountpassword=accountpassword;} public String getAccountpassword() {return accountpassword;} public void setAccountbalance(int accountbalance) {this.accountbalance=accountbalance;} public int getAccountbalance() {return accountbalance;} public void setAmount(int amount) {this.amount=amount;} public int getAmount() {return 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 Account() {} //参数统一类型 public String toString() { return (accountID+" "+accountname+" "+operatedate+" "+operatetype+" "+accountpassword+" "+accountbalance+" "+amount); } }
AccountManager类
//20173685 任伟强 信1705-2 import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; public class AccountManager extends Account{ //继承父类 public AccountManager(String accountID,String accountname,String operatedate,int operatetype,String accountpassword,int accountbalance,int amount) { super(accountID,accountname,operatedate,operatetype,accountpassword,accountbalance,amount); } public AccountManager() { } //全局定义 static Account a=new Account(); static Scanner s=new Scanner(System.in); //选择 public static void main(String[]args) { try { fileout(); waterout(); } catch (FileNotFoundException e1) { e1.printStackTrace(); } try { if(loginAccount()&&loginPwd()) { Menu(); String option; do { option=s.next(); switch(option) { case"1": handmoney();break; case"2": getmoney();break; case"3": moneygogogo();break; case"4": update();break; case"5": moneyhere();break; case "q": ;break; default: System.out.println("错误,请重新输入! "); }}while(!"q".equals(option)); System.out.println("成功退出系统! ");} } catch (IOException e) { e.printStackTrace(); } } //读取账户基本信息库 public static void fileout() throws FileNotFoundException { try { FileReader fr=new FileReader("D:eclipseeclipseAccountsrcaccountinformation.txt"); Scanner sc=new Scanner(fr); while(sc.hasNext()) { a.setAccountID(sc.next()); a.setAccountname(sc.next()); a.setAccountpassword(sc.next()); a.setAccountbalance(sc.nextInt()); } sc.close(); fr.close(); } catch (IOException e) { System.out.println("文件导出成功 "); } } //读取账户流水信息库 public static void waterout() throws FileNotFoundException { try { FileReader fr=new FileReader("D:eclipseeclipseAccountsrcaccountlist.txt"); Scanner sc=new Scanner(fr); while(sc.hasNext()) { a.setAccountID(sc.next()); a.setAccountname(sc.next()); a.setOperatedate(sc.next()); a.setOperatetype(sc.nextInt()); a.setAmount(sc.nextInt()); } sc.close(); fr.close(); } catch (IOException e) { System.out.println("文件导出成功 "); } } //导入账户基本信息库 public static void filein() throws IOException { int i; FileReader fr=new FileReader("D:eclipseeclipseAccountsrcaccountinformation.txt"); FileWriter fw=new FileWriter("D:eclipseeclipseAccountsrcaccountinformation.txt"); i=fr.read(); while(i!=-1) { fw.write(i); fr.read(); } fr.close(); fw.close(); } //导入账户基本信息库 public static void waterin() throws IOException { int i; FileReader fr=new FileReader("D:eclipseeclipseAccountsrcaccountlist.txt"); FileWriter fw=new FileWriter("D:eclipseeclipseAccountsrcaccountlist.txt"); i=fr.read(); while(i!=-1) { fw.write(i); fr.read(); } fr.close(); fw.close(); } //打印菜单 public static void Menu(){ StringBuffer s=new StringBuffer(" "); s.append(" ************************************************* "); s.append(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); s.append(" ************************************************* "); s.append(" 1.存款; "); s.append(" 2.取款; "); s.append(" 3.转账汇款; "); s.append(" 4.修改密码; "); s.append(" 5.查询余额; "); s.append(" ************************************************* "); s.append(" (输入q退出系统) "); s.append("请操作 "); System.out.println(s); } //打印登陆账号界面 public static boolean loginAccount() throws IOException { System.out.println(" ************************************************* "); System.out.println(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); System.out.println(" ************************************************* "); System.out.println(" 请输入您的账号: "); String checkAccount = s.next(); if (a.getAccountID().equals (checkAccount)){ System.out.println("输入账号成功,系统跳转到输入密码界面 "); return true ; }else { System.out.println("该账号不存在 "); return false ; } } //打印登陆密码界面 public static boolean loginPwd() throws IOException { System.out.println(" ************************************************* "); System.out.println(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); System.out.println(" ************************************************* "); for (int i = 3 ;i>0;i--){ System.out.println(" 请输入您的密码: "); String checkPwd = s.next(); if (a.getAccountpassword().equals (checkPwd)){ System.out.println("输入密码成功,系统跳转到主界面! "); return true ; }else { if ( i ==1 ){ System.out.println("该账号三次录入密码错误,该卡已被系统没收,请与工行及时联系处理 "); return false ; } System.out.println("密码录入错误!今日剩余次数:"+ (i-1)); } } return false; } //存款 private static void handmoney() { System.out.println(" ************************************************* "); System.out.println(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); System.out.println(" ************************************************* "); System.out.println(" 请输入存款金额: "); int number=s.nextInt(); a.setAccountbalance(a.getAccountbalance() + number); System.out.println(" ************************************************* "); System.out.println(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); System.out.println(" ************************************************* "); System.out.println(" 当前账户存款操作成功 "); System.out.println(" 当前账户余额为"+a.getAccountbalance()+"元 "); System.out.println(" ************************************************* "); Menu(); System.out.println(" 请继续操作 "); } //取款 public static void getmoney() { a.setAccountbalance(a.getAccountbalance()); System.out.println(" ************************************************* "); System.out.println(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); System.out.println(" ************************************************* "); System.out.println(" 当前账户每日可以支取2万元 "); System.out.println(" 1.100元 "); System.out.println(" 2.500元 "); System.out.println(" 3.1000元 "); System.out.println(" 4.1500元 "); System.out.println(" 5.2000元 "); System.out.println(" 6.5000元 "); System.out.println(" 7.其他金额 "); System.out.println(" 8.退卡 "); System.out.println(" 9.返回 "); System.out.println(" ************************************************* "); int num1=100,num2=500,num3=1000,num4=1500,num5=2000,num6=5000; int str=s.nextInt(); if (a.getAccountbalance() <str ){ System.out.println("账户余额不足!! "); str=0; }else if(str==1){ a.setAccountbalance(a.getAccountbalance() - num1); }else if(str==2){ a.setAccountbalance(a.getAccountbalance() - num2); }else if(str==3){ a.setAccountbalance(a.getAccountbalance() - num3); }else if(str==4){ a.setAccountbalance(a.getAccountbalance() - num4); }else if(str==5){ a.setAccountbalance(a.getAccountbalance() - num5); }else if(str==6){ a.setAccountbalance(a.getAccountbalance() - num6); }else if(str==7){ str=s.nextInt(); a.setAccountbalance(a.getAccountbalance() - str); }else if(str==8){ System.out.println("退卡成功 "); }else if(str==9){ System.out.println("返回成功 "); } System.out.println(" ************************************************* "); System.out.println(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); System.out.println(" ************************************************* "); System.out.println(" 当前账户存款操作成功 "); System.out.println(" 当前账户余额为"+a.getAccountbalance()+"元 "); System.out.println(" ************************************************* "); Menu(); } //转账汇款 public static void moneygogogo() { a.setAccountbalance(a.getAccountbalance()); System.out.println(" ************************************************* "); System.out.println(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); System.out.println(" ************************************************* "); System.out.println(" 请输入转账账户 "); String str=s.next(); if(a.getAccountID().equals(str)) { System.out.println(" ************************************************* "); System.out.println(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); System.out.println(" ************************************************* "); System.out.println(" 请输入转账金额 "); int num=s.nextInt(); if(a.getAccountbalance()<=num){ System.out.println("账户余额不足 "); }else { a.setAccountbalance(a.getAccountbalance() - num); System.out.println(" ************************************************* "); System.out.println(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); System.out.println(" ************************************************* "); System.out.println(" 当前账户向"+a.getAccountID()+"成功转账"+str+"元"); System.out.println(" 当前账户余额为"+a.getAccountbalance()+"元 "); System.out.println(" ************************************************* "); } } Menu(); } //修改密码 public static void update() throws IOException { fileout(); System.out.println(" ************************************************* "); System.out.println(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); System.out.println(" ************************************************* "); System.out.println(" 请输入当前密码: "); String str=s.next(); if(!a.getAccountpassword().equals(str)) { System.out.println("当前密码录入错误"); }else { System.out.println(" 请输入修改密码: "); String str1=s.next(); System.out.println(" 请输入确认密码: "); String str2=s.next(); if(!str1.equals(str2)) { System.out.println("修改密码与确认密码不一致 "); }else { System.out.println(" ************************************************* "); System.out.println(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); System.out.println(" ************************************************* "); System.out.println(" 当前账户密码修改成功"); System.out.println(" ************************************************* "); } } Menu(); } //查询余额 public static void moneyhere() { System.out.println(" ************************************************* "); System.out.println(" 欢迎全世界最有钱的人使用中国工商银行自助柜员系统 "); System.out.println(" ************************************************* "); System.out.print(" 当前账户余额为"+a.getAccountbalance()+"元 "); System.out.print(" 账户清单信息为: "); System.out.print(" 操作日期"+a.getOperatedate()+" 操作类型"+a.getOperatetype()+"操作金额"+a.getAmount()+" "); System.out.println(" ************************************************* "); Menu(); } }
javaatm机数据库
请尽量用简单的代码写,我是初学者,太复杂了老师就知道不是我们写的,还有就是连接数据库不要用ACESS,用SQL模拟银行ATM自动取款机的操作。当用户插入有效的银行卡时,可以对用户的银行卡种类做出判断(借记卡还是信用... 查看详情
javaatm底层结构解释
一个业务需要做成一共有三层:界面层(用户层)-----》业务逻辑层(业务层)--------》数据访问层上面的没有一个层都实现后,需要进行回调,应为她们都是接口数据访问层实现类-----》业务逻辑层实... 查看详情
实验三进程调度模拟程序2.0
实验三进程调度模拟程序2.0一、实验目的用高级语言完成一个进程调度程序,以加深对进程的概念及进程调度算法的理解。二、实验内容和要求设计一个有N个进程并发执行的进程调度模拟程序。1.模拟进程数据的生成允许用户指... 查看详情
在导航应用程序中使用模拟位置
】在导航应用程序中使用模拟位置【英文标题】:UsingaMockLocationinNavigationApp【发布时间】:2011-10-2715:34:55【问题描述】:我正在尝试开发一个应用程序来模拟通过Google导航应用程序的路线。我在本网站(Androidmocklocationondevice?)的其... 查看详情
淘宝试用模拟点击程序
一个模拟点击事件的程序。试用python语言。循环点击淘宝试用的宝贝,由于平时中过几次淘宝试用。认为有这种机会白不用,所以自己写了个小程序,免去人为琐碎的点击申请宝贝。代码开源在githubhttps://github.com/Rockyzsu/TaobaoTrial 查看详情
淘宝试用模拟点击程序
一个模拟点击事件的程序。试用python语言。循环点击淘宝试用的宝贝。由于平时中过几次淘宝试用,认为有这种机会白不用,所以自己写了个小程序,免去人为琐碎的点击申请宝贝。代码开源在githubhttps://github.com/Rockyzsu/TaobaoTrial 查看详情
ios模拟器:如何关闭应用程序
】ios模拟器:如何关闭应用程序【英文标题】:iossimulator:howtocloseanapp【发布时间】:2013-09-0209:49:43【问题描述】:当您从xCode“运行”模拟器时,应用程序会自动启动,然后您可以单击主页按钮暂停应用程序。我想做的是从模拟... 查看详情
iphone应用程序无法运行ipad模拟器
】iphone应用程序无法运行ipad模拟器【英文标题】:iphoneappnotworkingipadsimulator【发布时间】:2011-11-0904:41:26【问题描述】:我的iphone应用程序可以在iphone模拟器和设备上运行,但不能在ipad模拟器上运行。它没有显示任何错误,但... 查看详情
如何模拟 C# 应用程序的配置
】如何模拟C#应用程序的配置【英文标题】:HowtomockconfigurationforC#application【发布时间】:2016-07-1814:40:28【问题描述】:我编写了一个C#应用程序并想模拟配置值。比如我在远程机器上配置了一个文件创建路径,想在测试的时候在... 查看详情
Windows 应用程序中的模拟
】Windows应用程序中的模拟【英文标题】:Impersonationinwindowsapplication【发布时间】:2010-02-2315:20:18【问题描述】:我编写了一个非常简单的程序来从一个路径加载xml并将其存储在所有用户/应用程序数据中。但我收到拒绝访问错误... 查看详情
未从 LocationManager 中清除的 Android 模拟位置提供程序
】未从LocationManager中清除的Android模拟位置提供程序【英文标题】:AndroidmocklocationprovidersnotcleanedfromLocationManager【发布时间】:2011-12-1210:10:28【问题描述】:我遇到了模拟位置提供程序的问题。我有一个需要获取准确有效位置的... 查看详情
模拟登陆python程序(代码片段)
写一个简单的模拟登陆python程序模拟登录一:a='zhangsan'b='123456'defsystem():ifname==aandpassword==b:return'欢迎登入系统!'elifname!=aandpassword==b:ret 查看详情
在桌面应用程序中通过 *** 模拟用户
】在桌面应用程序中通过***模拟用户【英文标题】:Impersonateuserovera***inadesktopapplication【发布时间】:2019-10-2006:40:14【问题描述】:我在尝试在桌面应用程序中模拟ActiveDirectory用户时遇到问题。每次我使用LogOnAPI时,结果都是错... 查看详情
抽卡程序模拟
0引言手机抽卡游戏的爆火,让我们萌生了用程序来模拟游戏中的抽卡这一环节。1问题对抽卡手游的抽卡这一环节进行模拟。2方法用python的random函数进行模拟。3实验结果与讨论通过实验、实践等证明提出的方法是有效的... 查看详情
Sharepoint - 模拟应用程序池身份
】Sharepoint-模拟应用程序池身份【英文标题】:Sharepoint-ImpersonatingAppPoolIdentity【发布时间】:2014-10-1618:20:22【问题描述】:我正在使用SPSecurity.RunWithElevatedPrivileges....允许“模拟”超级用户“sharepoint\\system”帐户。“sharepoint\\system... 查看详情
在 Android 模拟器上运行谷歌地图应用程序
】在Android模拟器上运行谷歌地图应用程序【英文标题】:RunninggooglemapapplicationonAndroidEmulator【发布时间】:2013-10-2217:40:43【问题描述】:我的应用程序使用GoogleMapsv2。此应用程序在Android设备上成功运行。我试图在Android模拟器上... 查看详情
微信单招模拟考试小程序怎么登录
微信单招模拟考试小程序登录方式有多种,一般有以下几种:1.微信扫码登录:在小程序内页面点击“扫描二维码登录”,打开微信扫码登录,使用微信扫码登录即可。2.微信账号登录:在小程序内页面点击“微信账号登录”,... 查看详情
ASP.NET - 在默认模拟用户时临时模拟应用程序池服务 ID?
】ASP.NET-在默认模拟用户时临时模拟应用程序池服务ID?【英文标题】:ASP.NET-temporarilyimpersonatetheapppoolserviceIDwhendefaultittoimpersonatetheuser?【发布时间】:2009-01-2720:45:49【问题描述】:我必须调用SharePoint网站中的一些代码,这些代... 查看详情