包含id, owner, amount, createtime, isVIP共5个成员变量(类型自定)
包含string getID()成员方法,用于返回银行账号
包含int getAmount()成员方法,用于返回账户金额
包含void depositAmount(int e)成员方法,用于实现存款e元的操作
包含void drawAmount(int e)成员方法,用于实现取款e元的操作
创建Customer类。
包含name,id,sex,age, address,phone共6个成员变量(类型自定)。
包含开户Account createAccount( )成员方法,返回值类型为Account型
包含查询账户void queryAccount(Account & e), 用于查询顾客的账户e的余额。
包含void drawAccount(Account & e, int m)成员函数,用于从账户e中取款m元。
包含void depositAccount(Account & e, int m)成员函数,用于向账户e中存款m元。
如果该类需要其它成员函数,请自己定义。
void main()
{
Account x;
Customer c(“张三”, “2002010”, “男”, 23, “柳台大道255号”, “1387722234”);
x=c.createAccount( );
c.queryAccount(x); //第一次查询余额
c.depositAccount(x, 1400); //向顾客的账户x中存款1400元
c.queryAccount(x); //第二次查询余额
c.drawAccount(x, 800); //从账户x取款800
c.queryAccount(x); //第三次查询余额
}
下面是我自己的程序
#include
#include
using namespace std;
struct Date
{
int year;
int month;
int day;
void set(int a,int b,int c)
{
a=year;
b=month;
c=day;
}
};
class Account
{
public:
string id;
string owner;
Date createtime;
int amount;
bool isvip;
string getID(Account x)
{
return x.id;
}
int getAmount(Account y)
{
return y.amount;
}
void depositAmount(Account x,int e)
{
x.amount=x.amount+e;
}
void drawAmount(Account x,int e)
{
x.amount=x.amount-e;
}
};
class Customer
{
string name;
int id;
string sex;
int age;
string address;
int phone;
public:
Account createAccount(Customer x)
{
Date i;
Account a(x.id,x.name,i,0,0);
return a;
}
void queryAccount(Account & e)
{
cout<
void drawAccount(Account & e, int m)
{
e.amount=e.amount-m;
}
void depositAccount(Account & e, int m)
{
e.amount=e.amount+m;
}
};
void main()
{
Account x;
Customer c("张三", 2002010, "男", 23, "柳台大道25",1387722234);
x=c.createAccount( );
c.queryAccount(x); //第一次查询余额
c.depositAccount(x, 1400); //向顾客的账户x中存款1400元
c.queryAccount(x); //第二次查询余额
c.drawAccount(x, 800); //从账户x取款800
c.queryAccount(x); //第三次查询余额
}
谢谢谢谢~~~