⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.cpp

📁 本程序给出了SSD5实验课中Exercise6的参考程序 内附有详细的注释 下载后请仔细参照源代码进行分析 切莫完全搬照
💻 CPP
字号:
#pragma warning (disable:4786)
#pragma warning (disable:4503)
/*
 * Class Client models a registered user of the auction system.
 * This class contains private data members to store the first name,
 * last name, email address, and password of the user.
 */
#include "Client.h"

//Initializes the private data members to default values 
Client::Client(void) {

	fname = "";
	lname = "";
	email = "";
	passwd = "";
}

//Accepts parameters to initialize the private data members 
Client::Client(string &fname, string &lname, string &email, string &passwd){

	this->fname = fname;
	this->lname = lname;
	this->email = email;
	this->passwd = passwd;
}

//Makes a copy of a Client object 
Client::Client(Client const &c) {

	fname = c.getFname();
	lname = c.getLname();
	email = c.getEmail();
	passwd = c.getPasswd();
}

//Provide access to the private data members
void Client::setFname(const string& s) {

	fname = s;
}

void Client::setLname(const string& s) {

	lname = s;
}

void Client::setEmail(const string& s) {

	email = s;
}

void Client::setPasswd(const string& s) {

	passwd = s;
}

string Client::getFname() const{

	return fname;
}

string Client::getLname() const{

	return lname;
}

string Client::getEmail() const{

	return email;
}

string Client::getPasswd() const{

	return passwd;
}

//Returns true if the invoking object's password matches the password given in the parameter, false if otherwise.
bool Client::verifyPasswd(string passwd) {

	return (this->passwd == passwd);
}

//This method reads a Client object from an input stream.
istream &operator>>(istream &stream, Client &c) {

    string fname;
    string lname;
    string email;
    string passwd;

	stream >> fname;
	stream >> lname;
	stream >> email;
	stream >> passwd;

	c.setFname(fname);
	c.setLname(lname);
	c.setEmail(email);
	c.setPasswd(passwd);
	return stream;
}

//Returns a begin iterator for the offerings vector 
set<int>::iterator Client::beginOfferings() {
	return offerings.begin();
}

//Returns an end iterator for the offerings vector
set<int>::iterator Client::endOfferings() {
	return offerings.end();
}

//Returns a begin iterator for the bids vector
set<int>::iterator Client::beginBids() {
	return bids.begin();
}

//Returns an end iterator for the bids vector 
set<int>::iterator Client::endBids() {
	return bids.end();
}

//Adds an advertisement number to the bids vector
void Client::addBid(int item) {
	bids.insert(item);
}

//Adds an advertisement number to the bids vector
void Client::addOffering(int item) {
	offerings.insert(item);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -