package com.lw.thread;
/* Bank account type Account (cannot be overdrafted), including account ID (10~16 digits), password (6 digits) , name of the head of household, balance */
public class Account {
private String id;
private int password;
private String name;
private double balance;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getPassword() {
return password;
}
public void setPassword(int password) {
this.password = password;
}
p>public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getBalence() {
return balance;
}
public void setBalence(double balence) {
this.balence = balence;
}
/*
* Default The constructed account information is: 11111111111111111, 666666, Qian Sanduo, 888888.88.
*/
public Account() {
super();
this.id = "1111111111111111";
this.password = 666666;
this.name = "Qian Sanduo";
this.balance = 888888.88;
} p>
/*
* Another construction method takes 4 parameters to initialize 4 properties (with data validity verification).
*/
public Account(String id, int password, String name, double balance) {
this.id = id;
this.password = password;
this.name = name;
this.balence = balance;
}
/*
* Check balance
*/
public static double selectMoney(Account account) {
return account.getBalence();
}
/*
* Save money
*/
public static String setMoney(Account account, double balance) {
if (balence lt; 0) {
return "Failed to deposit money, please put it in correctly!";
}
double d = balance account.getBalence();
account.setBalence(d);
return "You deposited" balance "Yuan, the current account balance is" d;
}
/*
* Withdraw money
*/
public static String getMoney(Account account, double balance) {
double d = account.getBalence();
if (balence gt; d) {
return "Your balance is insufficient!";
}
account.setBalence(d - balance);
return "You took out" balance "Yuan, the current account balance is" account.getBalence();
}
}