资源简介
该系统实现了查询、取款、转账、存款等功能,有一定的学习参考价值。
代码片段和文件信息
package cn.itcareers;
import cn.itcareers.model.Account;
import cn.itcareers.service.OperateAccount;
import cn.itcareers.service.OperateAccountImpl;
import cn.itcareers.util.ReadUtil;
public class Client {
public static void main(String[] args) {
int chose = 0;
OperateAccount oa = new OperateAccountImpl();
Account account = null;
outer: while ((chose = ReadUtil.printMenu()) != 0) {
switch (chose) {
case 0:
break outer;
case 1: {// 用户选择了1,进行添加帐号的操作
System.out
.println(“请输入用户名,密码,储蓄金额,身份证号,注意,开户金额不能少于10元,且输入顺序必须与提示一致“);
String[] str = ReadUtil.readStringArray(4);
account = new Account();
account.setName(str[0]);
account.setPassword(str[1]);
double m;
try {
m = Double.parseDouble(str[2]);
} catch (NumberFormatException e) {
System.out.println(“储蓄金额请输入数字“);
m = ReadUtil.readDouble();
}
account.setBalance(m);
account.setIdCard(str[3]);
account = oa.addAccount(account);
int ch;
if (account != null) {
System.out.println(“您的帐号是:“ + account.getCardNum()
+ “,请记录您的帐号“);
ch = ReadUtil.printSubMenu();
} else {
ch = ReadUtil.printErrorMenu();
}
switch (ch) {
case 0:
break outer;
case 1:
continue outer;
}
}
break;
case 2: {// 用户选择了2 ,进行储蓄操作
if (account == null) {// 如果卡号为空,证明用户是首次进入,则需要提示用户输入卡号和密码
System.out.println(“请输入卡号和密码:“);
String[] str = ReadUtil.readStringArray(2);
account = oa.getAccount(str[0] str[1]);
}
// 如果用户给定帐号和密码无误,则进行储蓄操作
if (account != null) {
System.out.println(“请输入储蓄金额:“);
double m = ReadUtil.readDouble();
oa.saveMoney(account m);
int ch = ReadUtil.printSubMenu();
switch (ch) {
case 0:
break outer;
case 1:
continue outer;
}
} else {// 如果用户输入有误,则提示用户重新输入
System.out.println(“您输入的帐号或密码有误,请重新输入“);
int ch = ReadUtil.printErrorMenu();
switch (ch) {
case 0:
break outer;
case 1:
continue outer;
}
}
}
break;
case 3: {// 如果用户选择了3,进得取款操作
if (account == null) {// 如果卡号为空,证明用户是首次进入,则需要提示用户输入卡号和密码
System.out.println(“请输入卡号和密码:“);
String[] str = ReadUtil.readStringArray(2);
account = oa.getAccount(str[0] str[1]);
}
if (account != null) {// 如果用户输入无误,则进行取款操作
System.out.println(“请输入取款金额:“);
double m = ReadUtil.readDouble();
int ch;
if (m <= account.getBalance()) {// 如果取款不大于用户卡上余额,则进行取款操作
oa.drawMoney(account m);
ch = ReadUtil.printSubMenu();
} else {// 如果用户取款大于用户卡上余额,则提示用户余额不足
System.out.println(“卡上余额不足!“);
ch = ReadUtil.printErrorMenu();
}
switch (ch) {
case 0:
break outer;
case 1:
continue outer;
}
} else {// 如果用户输入帐号和密码不有误,则提示用户出错
System.out.println(“您输入的帐号或密码有误,请重新输入!“);
int ch = ReadUtil.printErrorMenu();
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 315 2009-04-07 13:18 banks\.classpath
文件 381 2009-04-03 21:22 banks\.project
文件 4472 2009-04-07 13:27 banks\bin\cn\itcareers\Client.class
文件 2256 2009-04-07 13:31 banks\bin\cn\itcareers\db\Databa
文件 1575 2009-04-07 13:23 banks\bin\cn\itcareers\model\Account.class
文件 515 2009-04-07 13:18 banks\bin\cn\itcareers\service\OperateAccount.class
文件 3738 2009-04-07 13:26 banks\bin\cn\itcareers\service\OperateAccountImpl.class
文件 2975 2009-04-07 13:18 banks\bin\cn\itcareers\util\ReadUtil.class
文件 179 2009-04-02 15:09 banks\create.txt
文件 6410 2009-04-07 13:27 banks\src\cn\itcareers\Client.java
文件 1498 2009-04-07 13:31 banks\src\cn\itcareers\db\Databa
文件 1077 2009-04-07 13:23 banks\src\cn\itcareers\model\Account.java
文件 869 2009-04-04 00:51 banks\src\cn\itcareers\service\OperateAccount.java
文件 2929 2009-04-07 13:26 banks\src\cn\itcareers\service\OperateAccountImpl.java
文件 2917 2009-04-06 21:42 banks\src\cn\itcareers\util\ReadUtil.java
..A..H. 162 2009-06-04 02:54 banks\~$假期作业.doc
文件 11264 2009-03-31 19:59 banks\假期作业.doc
文件 1388 2009-06-04 02:55 banks\功能需求.txt
目录 0 2009-06-04 02:34 banks\bin\cn\itcareers\db
目录 0 2009-06-04 02:34 banks\bin\cn\itcareers\model
目录 0 2009-06-04 02:34 banks\bin\cn\itcareers\service
目录 0 2009-06-04 02:34 banks\bin\cn\itcareers\util
目录 0 2009-06-04 02:34 banks\src\cn\itcareers\db
目录 0 2009-06-04 02:34 banks\src\cn\itcareers\model
目录 0 2009-06-04 02:34 banks\src\cn\itcareers\service
目录 0 2009-06-04 02:34 banks\src\cn\itcareers\util
目录 0 2009-06-04 02:34 banks\bin\cn\itcareers
目录 0 2009-06-04 02:34 banks\src\cn\itcareers
目录 0 2009-06-04 02:34 banks\bin\cn
目录 0 2009-06-04 02:34 banks\src\cn
............此处省略6个文件信息
评论
共有 条评论