实训第一天 重构银行

/* (程序头部注释开始)
* 程序的版权和版本声明部分
* Copyright (c) 2011, 烟台大学计算机学院学生 
* All rights reserved.
* 文件名称:                              
* 作    者:   姜雅明                              
* 完成日期:    2012    年   08    月    21    日
* 版 本 号:    1.0       
* 程序头部的注释结束
*/

Record.h

#ifndef HEADER_RECORD
#define HEADER_RECORD
#include 
using namespace std;

class Record
{
private:
	int number;
	string userName;
	string passWord;
	double balance;
	int flag;
public:
	Record();

	void set_number(int number);
	void set_userName(string userName);
	void set_passWord(string passWord);
	void set_balance(double balance);
	void set_flag(int flag);

	int get_number();
	string get_userName();
	string get_passWord();
	double get_balance();
	int get_flag();

	void display_Record();
};
#endif


Record.cpp

#include "Record.h"
#include 
using namespace std;

Record::Record()
{
	this->number = 0;
	this->userName = "";
	this->passWord = "";
	this->balance = 0;
	this->flag = -1;
}

void Record::set_number(int number)
{
	this->number = number;
}

void Record::set_userName(string userName)
{
	this->userName = userName;
}

void Record::set_passWord(string passWord)
{
	this->passWord = passWord;
}

void Record::set_balance(double balance)
{
	this->balance = balance;
}

void Record::set_flag(int flag)
{
	this->flag = flag;
}

int Record::get_number()
{
	return this->number;
}

string Record::get_userName()
{
	return this->userName;
}

string Record::get_passWord()
{
	return this->passWord;
}

double Record::get_balance()
{
	return this->balance;
}

int Record::get_flag()
{
	return this->flag;
}

void Record::display_Record()
{
	cout << "---------------------------" << endl;
	cout << "Number: " << this->number << endl;
	cout << "UserName: " << this->userName << endl;
	cout << "PassWord: " << this->passWord << endl;
	cout << "Balance: " << this->balance << endl;
	cout << "flag: " << this->flag << endl;
	cout << "---------------------------" << endl;
}


测试用的    TestRecord.cpp

#include "Record.h"
#include 

int main()
{
	Record * record = new Record;
	record->display_Record();

	record->set_number(10001);
	record->set_userName("zhangsan");
	record->set_passWord("123456");
	record->set_balance(100000);
	record->set_flag(1);
	record->display_Record();

	cout << record->get_number() << endl;
	cout << record->get_userName() << endl;
	cout << record->get_passWord() << endl;
	cout << record->get_balance() << endl;
	cout << record->get_flag() << endl;
	
	return 0;
}

 

放了一个暑假,忘了好多,算是复习吧···

你可能感兴趣的:(实训项目,string,header,测试,c)