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

📄 advertisement.cpp

📁 卡内基梅隆大学ssd5数据结构的实验内容包括实验
💻 CPP
字号:
#include<iostream>
#include"Advertisement.h"

using namespace std;

/* Initializes the private data members to default values */
Advertisement::Advertisement(void):title(""), seller_email(""), body(""), 
                   quantity(0){}

/* Accepts parameters to initialize the private data members */
Advertisement::Advertisement (string title, string seller_email, string body, Date start,
	Date close, int quantity):title(title),seller_email(seller_email),body(body),start(start),
	close(close),quantity(quantity){}

/* Makes a copy of a Advertisement object */
Advertisement::Advertisement(const Advertisement &a){

	start = a.getStart();
    close = a.getClose();
	title = a.getTitle();
    body = a.getBody();
    seller_email = a.getEmail();
    number = a.getNumber ();
    quantity = a.getQuantity();
   
}

/* Change the value of "start" */
void Advertisement::setStart (const Date &start){
	this->start = start;
}

/* Change the value of "close" */
void Advertisement::setClose (const Date &close){
	this->close = close;
}

/* Change the value of "title" */
void Advertisement::setTitle (string title){
	this->title = title;
}

/* Change the value of "body" */
void Advertisement::setBody (string body){
	this->body = body;
}

/* Change the value of "number" */
void Advertisement::setNumber (int number){
	this->number = number;
}

/* Change the value of "email" */
void Advertisement::setEmail (string email){
	this->seller_email = email;
}

/* Change the value of "quantity" */
void Advertisement::setQuantity (int quantity){
	this->quantity = quantity;
}

/* Get the value of "start" */
Date Advertisement::getStart() const{
	return start;
}

/* Get the value of "close" */
Date Advertisement:: getClose() const{
	return close;
}

/* Get the value of "title" */
string Advertisement::getTitle() const{
	return title;
}

/* Get the value of "body" */
string Advertisement::getBody() const{
	return body;
}

/* Get the value of "email" */
string Advertisement::getEmail() const{
	return seller_email;
}

/* Get the value of "number" */
int Advertisement::getNumber () const{
	return number;
}

/* Get the value of "quantity" */
int Advertisement::getQuantity() const{
	return quantity;
}
 
/* 
 * Compares Advertisement objects for equality. 
 * Two Advertisement objects are equal if their 
 * identification numbers are equal. 
*/  
bool Advertisement::operator==(const Advertisement& num) const{
    if(number == num.getNumber()){
		return true;
	}
	else 
		return false;
}

/* This method reads an Advertisement object from an input stream*/
istream &operator>>(istream &stream, Advertisement &a){
	
	string m;
	int n;
	Date h;
	char b;

	stream >> m;
	a.setTitle(m);
	stream >> b;

	stream >> m;
	a.setEmail(m);
	stream >> b;

	stream >> n;
	a.setQuantity(n);
	stream >> b;

	stream >> h;
	a.setStart(h);
	stream >> b;

	stream >> h;
	a.setClose(h);
	stream >> b;

	stream >> m;
	a.setBody(m);
	stream >> b;

	return stream;

}

⌨️ 快捷键说明

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