深セン大学ジルアン「オブジェクト指向プログラミング」実験 11 多重継承

A. 非常勤大学院生(多重継承)

トピックの説明

1. 次のクラス継承構造を作成します。

1) 人事クラス CPeople を定義します。その属性 (保護タイプ) は、名前、性別、年齢です。

2) 学生クラス CStudent は CPeople クラスから派生し、次の属性が追加されます。学生番号と入学スコア。

3) 教師クラス CTeacher は CPeople クラスから派生し、次の属性が追加されます。

4) CStudent クラスと CTeacher クラスから、勤務中の大学院クラス CGradOnWork が派生し、属性: 研究の方向性、チューターが追加されます。

2. 上記のクラスのコンストラクター、出力関数 print およびその他の関数 (必要な場合) を定義します。

3. main 関数でさまざまなタイプのオブジェクトを定義し、テストします。

入力

1行目: 名前 性別 年齢

2行目:生徒数スコア

3行目: 職務部門

4行目:研究指導講師

出力

最初の行: 人物:

2行目以降:書式はサンプルを参照

入力サンプル1

wang-li m 23
2012100365 92.5
アシスタントコンピューター
ロボット 趙軍

出力サンプル1

人物:
名前: wang-li
性別: 男性
年齢: 23

学生:
名前: wang-li
性別: 男性
年齢: 23
番号: 2012100365
スコア: 92.5

先生:
名前: wang-li 性別
: 男性
年齢: 23
役職: アシスタント
部署: コンピュータ

GradOnWork:
名前: wang-li
性別: 男性
年齢: 23
番号: 2012100365
スコア: 92.5
役職: アシスタント
部門: コンピューター
ディレクション: ロボット
講師: zhao-jun

ACコード

#include<bits/stdc++.h>
using namespace std;

class CPeople {
    
    
protected:
	string name;
	string sex;
	int age;
public:
	CPeople(string n, string s, int a) :name(n), sex(s), age(a) {
    
    }
	void print() {
    
    
		cout << "People:" << endl;
		cout << "Name: " << name << endl;
		cout << "Sex: " << sex << endl;
		cout << "Age: " << age << endl;
		cout << endl;
	}
};

class CStudent :virtual public CPeople {
    
    
protected:
	string id;
	double grade;
public:
	CStudent(string n, string s, int a, string id, double g) :CPeople(n, s, a), id(id), grade(g) {
    
    }
	void print() {
    
    
		cout << "Student:" << endl;
		cout << "Name: " << name << endl;
		cout << "Sex: " << sex << endl;
		cout << "Age: " << age << endl;
		cout << "No.: " << id << endl;
		cout << "Score: " << grade << endl;
		cout << endl;
	}
};


class CTeacher :virtual public CPeople {
    
    
protected:
	string position, department;
public:
	CTeacher(string n, string s, int a, string p, string d) :CPeople(n, s, a), position(p), department(d) {
    
    }
	void print() {
    
    
		cout << "Teacher:" << endl;
		cout << "Name: " << name << endl;
		cout << "Sex: " << sex << endl;
		cout << "Age: " << age << endl;
		cout << "Position: " << position << endl;
		cout << "Department: " << department << endl;
		cout << endl;
	}
};


class CGradOnWork :public CStudent, public CTeacher {
    
    
protected:
	string direction, tutor;
public:
	CGradOnWork(string n, string s, int a, string id, double g, string p, string d, string dir, string tu) :
		CPeople(n, s, a),
		CStudent(n, s, a, id, g),
		CTeacher(n, s, a, p, d),
		direction(dir),
		tutor(tu)
	{
    
    

	}

	void print() {
    
    
		cout << "GradOnWork:" << endl;
		cout << "Name: " << name << endl;
		cout << "Sex: " << sex << endl;
		cout << "Age: " << age << endl;
		cout << "No.: " << id << endl;
		cout << "Score: " << grade << endl;
		cout << "Position: " << position << endl;
		cout << "Department: " << department << endl;
		cout << "Direction: " << direction << endl;
		cout << "Tutor: " << tutor << endl;
		cout << endl;
	}

};


int main() {
    
    
	string s1, s2;
	int s3;
	string s4;
	double s5;
	string s6, s7, s8, s9;
	cin >> s1 >> s2 >> s3 >> s4 >> s5 >> s6 >> s7 >> s8 >> s9;
	CPeople(s1, s2, s3).print();
	CStudent(s1, s2, s3, s4, s5).print();
	CTeacher(s1, s2, s3, s6, s7).print();
	CGradOnWork c(s1, s2, s3, s4, s5, s6, s7, s8, s9);
	c.print();
	return 0;
}

B. 車両 (多重継承)

トピックの説明

1. 次のクラス継承構造を作成します。

1) 車のクラス CVehicle を基本クラスとして、max_speed、speed、weight などのデータ メンバーと、display() などのメンバー関数を持ちます。

2) 自転車クラス CBicycle は CVehicle クラスから派生し、次の属性が追加されます: height

3) 自動車クラス CMotocar は CVehicle クラスから派生し、属性が追加されます: 座席数 Seat_num

4) オートバイ クラス Cmotocycle は、CBicycle と Cmotocar から派生しています。

2. 上記のクラスのコンストラクター、出力関数表示およびその他の関数 (必要な場合) を定義します。

3. main 関数でさまざまなタイプのオブジェクトを定義し、それらをテストし、オブジェクトを通じて表示関数を呼び出して出力を生成します。

入力

1行目:最高速度・速度・体重 2行目:高さ 3行目:座席数

出力

1行目:Vehicle:2行目以降:フォーマットはサンプルを参照

入力サンプル1

100 60 20
28
2

出力サンプル1

車両:
最高速度:100
速度:60
重量:20

自転車:
最高速度:100
速度:60
重量:20
高さ:28

自動車:
最高速度:100
速度:60
重量:20
座席数:2

バイク:
最高速度:100
速度:60
重量:20
高さ:28
座席数:2

ACコード

#include<bits/stdc++.h>
using namespace std;

class CVehicle {
    
    
protected:
	int max_speed, speed, weight;
public:
	CVehicle(int ms, int sp, int we) :max_speed(ms), speed(sp), weight(we) {
    
    }


	void display() {
    
    
		cout << "Vehicle:" << endl;
		cout << "max_speed:" << max_speed << endl;
		cout << "speed:" << speed << endl;
		cout << "weight:" << weight << endl;
		cout << endl;
	}
};

class CBicycle :virtual public CVehicle {
    
    
protected:
	int height;
public:
	CBicycle(int ms, int sp, int we, int h) :
		CVehicle(ms, sp, we),
		height(h) {
    
    }



	void display() {
    
    
		cout << "Bicycle:" << endl;
		cout << "max_speed:" << max_speed << endl;
		cout << "speed:" << speed << endl;
		cout << "weight:" << weight << endl;
		cout << "height:" << height << endl;
		cout << endl;
	}
};

class CMotocar :virtual public CVehicle {
    
    
protected:
	int seat_num;
public:
	CMotocar(int ms, int sp, int we, int sn) :
		CVehicle(ms, sp, we),
		seat_num(sn) {
    
    }

	void display() {
    
    
		cout << "Motocar:" << endl;
		cout << "max_speed:" << max_speed << endl;
		cout << "speed:" << speed << endl;
		cout << "weight:" << weight << endl;
		cout << "seat_num:" << seat_num << endl;
		cout << endl;
	}
};

class CMotocycle :public CBicycle, public CMotocar {
    
    
public:
	CMotocycle(int ms, int sp, int we, int h, int sn) :
		CVehicle(ms, sp, we),
		CBicycle(ms, sp, we, h),
		CMotocar(ms, sp, we, sn) {
    
    }

	void display() {
    
    
		cout << "Motocycle:" << endl;
		cout << "max_speed:" << max_speed << endl;
		cout << "speed:" << speed << endl;
		cout << "weight:" << weight << endl;
		cout << "height:" << height << endl;
		cout << "seat_num:" << seat_num << endl;
		cout << endl;
	}
};

int main() {
    
    
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	CVehicle(a, b, c).display();
	CBicycle(a, b, c, d).display();
	CMotocar(a, b, c, e).display();
	CMotocycle(a,b,c,d,e).display();

	return 0;
}

C. ビジネストラベルクレジットカード(多重継承)

トピックの説明

旅行 Web サイト (Journey.com を想定) と銀行は、総合旅行サービスの共同ブランド カードである Journey クレジット カードを開始します。これは、Journey 会員カードと銀行クレジット カードの機能を備えています。
ジャーニー会員カードには、会員カード番号(int)とジャーニーポイント(int)が記載されており、会員カードを通じて注文を行うと、注文金額に応じてジャーニーポイントが蓄積されます。
クレジット カードの場合は、カード番号 (int)、名前 (string)、金額 (int)、請求額 (float)、およびクレジット カード ポイント (int) があります。------データ型にご注意ください。
クレジットカード利用額mに既存の請求額を加算して上限を超える場合は何も行わず、それ以外の場合は請求額+mとなり、利用額に応じてクレジットカードのポイントが蓄積されます。
クレジット カードの払い戻し m、請求金額 - m、クレジット カードのポイントから払い戻し金額を差し引いたもの。
Journey クレジット カードを使用して Journey.com で注文すると、Journey ポイントとクレジット カード ポイントの両方で 2 倍のポイントを獲得できます (つまり、Journey ポイントとクレジット カード ポイントの両方が同時に追加されます)。
トラベルクレジットカードは、トラベルポイント:クレジットカードポイント=1:2の割合でクレジットカードポイントをトラベルポイントに交換できます。
当初はクレジットカードのポイント、トラベルポイント、請求金額が0であると仮定します。
上記の内容に従って、旅行会員カード クラスとクレジット カード クラスを定義し、その 2 つから旅行クレジット カード クラスを導出し、3 つのクラスのコンストラクターとその他の必要な関数を定義します。
Journey クレジット カード オブジェクトを生成し、カード情報を入力し、オブジェクト メンバー関数を呼び出して、Journey.com での注文、クレジット カードのスワイプ、クレジット カードの払い戻し、クレジット カード ポイントから Journey ポイントへの変換などの操作を完了します。

入力

1行目:旅行会員証番号、クレジットカード番号、氏名、金額、2行
目:検査数n、
3行目〜n+2行、各行:操作金額またはポイントを入力
om (Journey.comでの注文、注文金額m)
cm (クレジットカードの消費、消費金額m)
qm (クレジットカードの返金、返金金額m)
tm (ポイント交換、クレジットカードのmポイントをジャーニーポイントに変換)

出力

操作後に旅行クレジットカードのすべての情報を出力します:
旅行番号、旅行ポイント、
クレジットカード番号、名前、請求金額、クレジットカードポイント

入力サンプル1

1000 2002 リリ 3000
4
o 212.5
c 300
q 117.4
t 200

出力サンプル1

1000 312
2002 リリ 395.1 195

ACコード

#include<bits/stdc++.h>
using namespace std;

class Member {
    
    
protected:
	int id;
	int score;
public:
	Member(int i, int s = 0) :id(i), score(s) {
    
    }
	void display() {
    
    
		cout << id << " " << score << endl;
	}
};


class Credit {
    
    
protected:
	int id;
	string name;
	int balance;//额度
	float value;//账单金额
	int score;
public:
	Credit(int i, string n, int b) :
		id(i),
		name(n),
		balance(b),
		value(0),
		score(0) {
    
    }

	void display() {
    
    
		cout << id << " " << name << " " << value << " " << score << endl;
	}
};


class MyClass :
	public Member,
	public Credit
{
    
    
public:
	MyClass(int mid, int cid, string name, int ba) :
		Member(mid),
		Credit(cid, name, ba) {
    
    }

	void o() {
    
    
		float m;
		cin >> m;
		if (m + value > balance)
			return;
		value += m;
		Member::score += (int)m;
		Credit::score += (int)m;
	}

	void c() {
    
    
		float m;
		cin >> m;
		if (m + value > balance)
			return;
		value += m;
		Credit::score += (int)m;
	}

	void q() {
    
    
		float m;
		cin >> m;
		Credit::score -= (int)m;
		value -= m;
	}

	void t() {
    
    
		float m;
		cin >> m;
		Credit::score -= m;
		Member::score += m / 2.0;
	}

	void display() {
    
    
		Member::display();
		Credit::display();
	}

};


int main() {
    
    
	int s1, s2, s4;
	string s3;
	cin >> s1 >> s2 >> s3 >> s4;
	MyClass mm(s1, s2, s3, s4);
	int n;
	cin >> n;
	while (n--) {
    
    
		char c;
		cin >> c;
		switch (c)
		{
    
    
		case 'o':
			mm.o();
			break;
		case 'c':
			mm.c();
			break;
		case 'q':
			mm.q();
			break;
		case 't':
			mm.t();
		default:
			break;
		}
	}
	mm.display();
}

D.スケジュール(多重継承+フレンド機能)

トピックの説明

すでに日付クラス Date があり、3 つの保護されたメンバー データ年、月、日が含まれています。

もう 1 つの時間クラス Time があり、これには 3 つの保護されたメンバー データ、時、分、秒、および 12 時間制が含まれます。

ここで、入力されたスケジュールの日時に従って前後のシーケンスを配置する必要があるため、Date クラスと Time クラスに基づいて、次の新しいメンバーを含むスケジュール クラス Schedule が確立されます。

int ID; //スケジュールID

フレンド関数 bool before(const Schedule & s1, const Schedule & s2);//スケジュール s1 の時間がスケジュール s2 より早いかどうかを判定します。

main関数を記述し、入力されたスケジュール情報に従ってスケジュールオブジェクトを作成し、最も早く調整する必要があるスケジュールを検索し(日時が等しい場合は、先に作成したスケジュールを出力します)、スケジュールオブジェクトの情報を出力します。 。

入力

テスト入力には複数のスケジュールが含まれており、各スケジュールは 1 行 (スケジュール ID、日付、スケジュール、時間) を占めます。

0 を読み出した場合は入力が終了し、対応する結果は出力されません。

出力

最近のスケジュール

入力サンプル1

1 2019 6 27 8 0 1
2 2019 6 28 8 0 1
3 2020 1 1 8 0 0
0

出力サンプル1

緊急予定その1:2019/06/27 08:00:01

ACコード

#include<bits/stdc++.h>
using namespace std;

class Date {
    
    
protected:
	int year, month, day;
public:
	Date(int y,int m,int d) {
    
    
		year = y;
		month = m;
		day = d;
	}

	void print()const {
    
    
		cout << setfill('0') << setw(2) << year << "/" << setfill('0') << setw(2) << month << "/" << setfill('0') << setw(2) << day;
	}
};

class Time {
    
    
protected:
	int hour, minute, second;
public:
	Time(int h,int m,int s) {
    
    
		hour = h;
		minute = m;
		second = s;
	}

	

	void print()const {
    
    
		cout << setfill('0') << setw(2) << hour << ":" << setfill('0') << setw(2) << minute << ":" << setfill('0') << setw(2) << second;
	}
};


class Schedule :
	public Date,
	public Time
{
    
    
	int id;



public:
	Schedule(int id,int y,int m,int d,int h,int min,int s):
		Date(y,m,d),
		Time(h,min,s)
	{
    
    
		this->id = id;
	}

	void print()const {
    
    
		cout << "The urgent schedule is No." << id << ": ";
		Date::print();
		cout << " ";
		Time::print();
		cout << endl;
	}


	bool operator < (const Schedule& s) const {
    
    
		if (year != s.year)
			return year < s.year;
		if (month != s.month)
			return month < s.month;
		if (day != s.day)
			return day < s.day;
		if (hour != s.hour)
			return hour < s.hour;
		if (minute != s.minute)
			return minute < s.minute;
		if (second != s.second)
			return second < s.second;
	}

	friend bool before(const Schedule& s1,const Schedule& s2) {
    
    
		return s1 < s2;
	}
};



int main() {
    
    
	string s;
	set<Schedule>ss;
	while (getline(cin, s)) {
    
    
		if (s[0] == '0')
			break;
		istringstream fin(s);
		int a, b, c, d, e, f, g;
		fin >> a >> b >> c >> d >> e >> f >> g;
		Schedule sss(a, b, c, d, e, f, g);
		ss.insert(sss);
	}

	(*ss.begin()).print();
	return 0;
}

E. 赤ちゃん口座の所得の計算(多重相続)

トピックの説明

ID 番号 (id, char[20]) と名前 (name, char[10]) の 2 つのデータ メンバーを持つクラス CPeople を定義し、CPeople クラスから CInternetUser クラスと CBankCustomer クラスを派生し、さらに CInternetUser と CBankCustomer から派生します。 多重継承CInternetBankCustomer クラスを派生します。

CInternetUserクラスにはログインパスワード(password, char[20])属性とregister register(id、名前、パスワードの設定)、loginログイン(入力されたidとパスワードがオブジェクトに登録されているものと同じかどうか判定)のメンバー関数があります。 。

CBankCustomer クラスには、balance (balance、double) 属性と、口座開設 openAccount (顧客名と ID の設定)、預金預金、引き出しdrawal、およびデフォルト コンストラクターがあります。

CInternetBankCustomerクラスには、残高、前日残高、当日収入、今日1万元収入、前日収入1万元の5つのデータメンバーが含まれており、収入、ログインログイン(入力されたIDとパスワードが正しいかどうかの判断)インターネット ユーザーと同じであり、CBankCustomer から継承されたユーザー名と ID は CInternetUser から継承されたものと同じである必要があります)。CInternetBankCustomer クラスのオブジェクトは、当日の入金の収入は計算せず、翌日以降の収入しか計算できず、同日の出金の収入はありません。

以下に示すように、main 関数を参照して入力データをテストおよび設計できます。

void main()
{ int t, no_of_days, i; char i_xm[20]、i_id[20]、i_mm[20]、b_xm[20]、b_id[20]、ib_id[20]、ib_mm[20]; 二重のお金、利子。文字演算コード;



//テストケース数を入力 t
cin >> t;
while (t–)
{ //インターネットユーザー登録時のユーザー名、ID、ログインパスワードを入力cin >> i_xm >> i_id >> i_mm;

//銀行口座開設ユーザー名、ID
cin >> b_xm >> b_idを入力します。

//インターネットユーザーがログインするときのIDとログインパスワードを入力します
cin >> ib_id >> ib_mm;

CInternetBankCustomer ib_user;

ib_user.registerUser(i_xm, i_id, i_mm);
ib_user.openAccount(b_xm, b_id);

if (ib_user.login(ib_id, ib_mm) == 0) //インターネット ユーザー ログイン、ID がパスワードと一致せず、銀行口座名と ID がインターネット アカウント名と ID と異なる場合 { cout << "パスワードまたは ID が
正しくありません " < < endl; continue; }


//日数を入力してください
cin >> no_of_days;
for (i=0; i < no_of_days; i++)
{ //操作コード、金額、10,000 元の日収を入力してくださいcin >> op_code >> 金額 >> 利息; switch (op_code) { case 'S': //銀行からインターネット金融口座に入金case 's': if (ib_user.deposit(money) == 0) { cout << “銀行残高が足りません” << endl; continue; } Break ; case 'T': //インターネット金融から銀行口座へ送金case 't': if (ib_user.withdraw(money) == 0) { cout << “インターネット銀行の残高が足りません” << endl ; continue; } Break; case 'D': //銀行口座に直接入金case 'd': ib_user.CBankCustomer::deposit(money);























Break;
case 'W': //銀行口座から直接引き出し
case 'w':
if (ib_user.CBankCustomer::withdraw(money) == 0)
{ cout << “銀行残高が不足しています” << endl; continue; } Break; default: cout << “不正な入力” << endl; continue; } ib_user.setInterest(interest); ib_user.calculateProfit(); //ユーザー名、IDを出力//銀行残高を出力 //インターネット金融口座の残高を出力ib_user.print(); } } }
















入力

ユーザー インスタンスの数を入力します

登録時に最初のインターネット ユーザーのユーザー名、ID、ログイン パスワードを入力します。

最初のユーザーの銀行口座開設ユーザー名、ID を入力します

ログイン時に最初のインターネット ユーザーの ID とパスワードを入力します

最初のユーザー操作日数を入力してください

操作コード(S、T、D、W)の金額を循環的に入力すると、1日の収入は10,000元になります
...

出力

最初のユーザー名、ID を出力します。
最初のユーザーの銀行残高を出力します
。 最初のインターネット金融口座残高を出力します

入力サンプル1

2
張山 1234567890 222222
張山 1234567890
1234567890 222222
4
D 15000 0
s 8000 1.5
T 3000 1.55
w 2000 0
lisi 2014150000 abcdef
lisi 20141 50000
2014150000 123456

出力サンプル1

名前: zhangsan ID: 1234567890
銀行残高: 15000
インターネット銀行残高: 0

名前: zhangsan ID: 1234567890
銀行残高: 7000
インターネット銀行残高: 8000

名前: zhangsan ID: 1234567890
銀行残高: 10000
インターネット銀行残高: 5001.2

名前: zhangsan ID: 1234567890
銀行残高: 8000
インターネット銀行残高: 5001.98

パスワードまたはIDが間違っています

ACコード

#include<bits/stdc++.h>
using namespace std;

class CPeople {
    
    
protected:
	string id, name;
public:
	CPeople() {
    
    }
	CPeople(string id, string name) :
		id(id),
		name(name)
	{
    
    }

};


class CInternetUser :
	virtual public CPeople
{
    
    
protected:
	string password;
public:
	CInternetUser() {
    
    }
	CInternetUser(string name, string id, string password) :
		CPeople(id, name),
		password(password)
	{
    
    }

	bool login(string id, string passward) {
    
    
		return this->id == id && this->password == passward;
	}

	void registerUser(string name, string id, string password) {
    
    
		this->name = name;
		this->id = id;
		this->password = password;
	}


};

class CBankCustomer :
	virtual public CPeople
{
    
    
protected:
	double balance;
public:
	CBankCustomer() {
    
    
		balance = 0;
	}
	CBankCustomer(string name, string id, double balance) :
		CPeople(name, id),
		balance(balance)
	{
    
    }

	void openAccount(string name, string id) {
    
    
		this->name = name;
		this->id = id;
	}


	void deposit(double v) {
    
    
		balance += v;
	}

	bool withdraw(double v) {
    
    
		//这里需要判断?
		if (v > balance)
			return false;
		balance -= v;
		return true;
	}

};


class CInternetBankCustomer :
	public CInternetUser,
	public CBankCustomer
{
    
    
	double _balance;
	double yesBalance;//前一日余额
	double profit;//当日收益
	double profitW;//今日万元收益
	double yesprofitW;//上一日万元收益
	double vain;
public:
	CInternetBankCustomer() {
    
    
		vain = profit = yesBalance = _balance = 0;
	}

	//设置万元收益
	void setInterest(double interest) {
    
    
		profitW = interest / 10000.0;
	}

	void calculateProfit() {
    
    
		profit = yesBalance * yesprofitW;
		_balance += profit;
	}


	void print() {
    
    
		cout << "Name: " << name << " ID: " << id << endl;
		cout << "Bank balance: " << balance << endl;
		cout << "Internet bank balance: " << _balance << endl;
		cout << endl;
		yesBalance = _balance;
		yesprofitW = profitW;
	}

	// 银行 -> 互联网
	bool deposit(double v) {
    
    
		if (v > balance)
			return false;
		balance -= v;
		_balance += v;
		return true;
	}

	//互联网 -> 银行
	bool withdraw(double v) {
    
    
		if (v > _balance)
			return false;
		_balance -= v;
		balance += v;
		return true;
	}


};

int main()
{
    
    
	int t, no_of_days, i;
	string i_xm, i_id, i_mm, b_xm, b_id, ib_id, ib_mm;
	double money, interest;
	char op_code;

	//输入测试案例数t
	cin >> t;
	while (t--)
	{
    
    
		//输入互联网用户注册时的用户名,id,登陆密码
		cin >> i_xm >> i_id >> i_mm;

		//输入银行开户用户名,id
		cin >> b_xm >> b_id;

		//输入互联网用户登陆时的id,登陆密码
		cin >> ib_id >> ib_mm;

		CInternetBankCustomer ib_user;

		ib_user.registerUser(i_xm, i_id, i_mm);
		ib_user.openAccount(b_xm, b_id);

		if (ib_user.login(ib_id, ib_mm) == 0)  //互联网用户登陆,若id与密码不符;以及银行开户姓名和id与互联网开户姓名和id不同
		{
    
    
			cout << "Password or ID incorrect" << endl;
			continue;
		}

		//输入天数
		cin >> no_of_days;
		for (i = 0; i < no_of_days; i++)
		{
    
    
			//输入操作代码, 金额, 当日万元收益
			cin >> op_code >> money >> interest;
			switch (op_code)
			{
    
    
			case 'S':  //从银行向互联网金融帐户存入
			case 's':
				if (ib_user.deposit(money) == 0)
				{
    
    
					cout << "Bank balance not enough" << endl;
					continue;
				}
				break;
			case 'T':  //从互联网金融转入银行帐户
			case 't':
				if (ib_user.withdraw(money) == 0)
				{
    
    
					cout << "Internet bank balance not enough" << endl;
					continue;
				}
				break;
			case 'D':  //直接向银行帐户存款
			case 'd':
				ib_user.CBankCustomer::deposit(money);
				break;
			case 'W':  //直接从银行帐户取款
			case 'w':
				if (ib_user.CBankCustomer::withdraw(money) == 0)
				{
    
    
					cout << "Bank balance not enough" << endl;
					continue;
				}
				break;
			default:
				cout << "Illegal input" << endl;
				continue;
			}
			ib_user.setInterest(interest);
			ib_user.calculateProfit();
			//输出用户名,id
			//输出银行余额
			//输出互联网金融账户余额
			ib_user.print();
		}
	}
}

おすすめ

転載: blog.csdn.net/weixin_46655675/article/details/129325665