client.cpp

来自「SSD5 练习2 需要的自己下载」· C++ 代码 · 共 80 行

CPP
80
字号
/*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. The class declaration 
includes the following public members.*/
#include <iostream>
#include <string>
#include "Client.h"

//Default constructor 
Client::Client(void):fname(""),lname(""),email(""),passwd("") {}

//Four parameter constructor 
Client::Client(string &fname, string &lname, string &email, string &passwd) {
	this->fname = fname;
	this->lname = lname;
	this->email = email;
	this->passwd = passwd;
}

//Copy constructor
Client::Client(Client const &c) {
	fname = c.fname;
	lname = c.lname;
	email = c.email;
	passwd = c.passwd;
}

//Accessors and mutators 
void Client::setFname(const string& newfname) {
    fname = newfname;
}
void Client::setLname(const string& newlname) {
    lname = newlname;
}
void Client::setEmail(const string& newemail) {
    email = newemail;
}
void Client::setPasswd(const string& newpasswd) {
    passwd = newpasswd;
}

string Client::getFname() const {
    return fname;
}
string Client::getLname() const {
	return lname;
}
string Client::getEmail() const {
	return email;
}
string Client::getPasswd() const {
	return passwd;
} 

//virtual bool verifyPasswd(string passwd); 
bool Client::verifyPasswd(string passwd) {
	if (passwd == this->passwd)
	    return true;
	else 
		return false;
}

//operator>> 
istream &operator>>(istream &stream, Client &c) {
	string fname,lname,email,passwd;

	getline(stream,fname);
	c.setFname(fname);

	getline(stream,lname);
	c.setLname(lname);
    
	getline(stream,email);
	c.setEmail(email);

	getline(stream,passwd);
	c.setPasswd(passwd);

	return stream;
}

⌨️ 快捷键说明

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