个人银行账户信息
主函数
public class TestBank {
public static void main(String[] args) {
Customer c = new Customer();
c.name = "毛概";
c.cid = "111123";
c.tel = "10010";
c.address = "陕西";
Account a = new Account();
a.cid = "1111111111";
a.balance = 10;
a.cus = c;
System.out.println(c.say());
System.out.println(a.getInfo());
}
}
客户类
public class Customer {
String name;
String cid;
String tel;
String address;
String say(){
return "姓名:" + name + ",身份证号:" + cid + ",电话:" + tel + ",地址:" + address;
}
}
账户类
public class Account {
String cid;
double balance;
Customer cus;
String getInfo(){
return "卡号:" + cid + ",余额" + balance + ",户主的信息" + cus.say();
}
boolean withdraw(double money){
if(money > balance){
return false;
}
balance -= money;
return true;
}
boolean save(double money){
balance += money;
return true;
}
}