package 16;
import ;
import ;
import ;
import ;
public class Method {
static LinkedList<User> userList = new LinkedList<User>();
Scanner scan = new Scanner(System.in);
double mon;
static int cardNum = 100000;
static int Card = 0;
void saveMon(int Card, int i) {
/*存款方法
* 传入账号Card,循环变量i
*
*
*
*
*
*
*
* */
("您的名字是" + userList.get(i).getName());
("请输入存款金额");
try {
mon = ();
} catch (InputMismatchException e) {
();
} catch (RuntimeException e) {
();
}
userList.get(i).setYuE(mon);
("存入" + mon + "元");
("现在您的账号余额" + userList.get(i).getYuE());
}
void getMon(int Card, int i) {
/*取款方法
* 传入账号Card,循环变量i
*
*
*
*
*
*
*
* */
("您的名字是" + userList.get(i).getName());
("请输入取款金额");
try {
mon = ();
} catch (InputMismatchException e) {
();
}
if (mon < userList.get(i).getYuE()) {
userList.get(i).setYuE2(mon);
("取出" + mon + "元");
("现在您的账号余额" + userList.get(i).getYuE());
}
}
void cha(int Card, int i) {
/*查询方法
* 传入账号Card,循环变量i
*
*
*
*
*
*
*
* */
("您的名字是" + userList.get(i).getName());
("现在您的账号余额" + userList.get(i).getYuE());
}
void creatUser() {
/*创建用户方法,因为取款机不提供该功能,因此仅调用一次做测试使用
*
*
*
*
*
*
*
* */
String name = "";
String miMa = "";
("请输入姓名");
try {
name = scan.next();
} catch (RuntimeException e) {
();
}
("请输入密码");
try {
miMa = scan.next();
} catch (RuntimeException e) {
();
}
userList.add(new User(++cardNum, name, miMa));
("您的账号是:" + cardNum);
}
int dengLu() { //登录方法,判断用户是否存在以及密码是否正确
boolean tag = true;
String miMa;
("请输入账号");
try {
Card = ();
} catch (InputMismatchException e) {
();
} catch (RuntimeException e) {
();
}
("请输入密码");
miMa = scan.next();
for (int i = 0; i < userList.size(); i++) {
if (userList.get(i).hasNum(Card)) {
if (userList.get(i).getMiMa().equals(miMa)) {
return i;
} else {
("密码错误");
break;
}
} else {
}
}
("查无此号");
return -2;
复制代码