package second;
public class Test {
public static void main(String[] args) {
Bank bbt=new Bank();
Customer c=new Customer("hai","642226","123456",12);
Customer c1=new Customer("ma","642226","123456",12);
Customer c2=new Customer("li","642226","123456",12);
bbt.print();
}
}
class Bank{
int size;
Customer cs[]=new Customer[100];
//注册
public void register(Customer c) {
if(size<100) {
cs[size]=c;
size++;
}
}
//登陆
public boolean login(String name,String password) {
for(int i=0;i<size;i++) {
Customer c=cs[i];
if(c.name==name&&c.password==password) {
return true;
}
}return false;
}
public void getMoney(String id,double money) {
for(int i=0;i<size;i++) {
Customer c=cs[i];
if(c.id==id) {
c.money-=money;
}
}
}
public void saveMoney(String id,double money) {
for(int i=0;i<size;i++) {
Customer c=cs[i];
if(c.id==id) {
c.money+=money;
}
}
}
public void print() {
for(int i=0;i<size;i++) {
Customer c=cs[i];
System.out.println(c);
}
}
}
class Customer{
String name;
String id;
int age;
String password;
double money;
public Customer(String name, String id, String password, double money) {
this.name = name;
this.id = id;
this.password = password;
this.money = money;
}
}
银行里有很多的客户,银行提供了客户的注册,登陆,取钱,存钱等功能,银行最多支持100个客户,编写核心类及相关代码,注册若干用户,在控制台输出用户的信息
最新推荐文章于 2022-06-30 22:07:08 发布