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

📄 bidhistory.cpp

📁 1.注册功能 2.登录功能 3.退出系统功能 4.发布新广告功能 5.添加子目录功能 6.查找广告功能 7.广告排序功能 8.查看当前目录中的广告 9.查看当前目录及其子目录中的广告
💻 CPP
字号:
#include <sstream>
#include "bidhistory.h"
#include "Advertisement.h"
#include "Group.h"
#include "Client.h"
#include "main.h"
using namespace std;

void displayBidHistory(ostringstream &oss, Advertisement* ad)
{
	int total_quantity=ad->getQuantity();
    Date start=ad->getStart();
    Date close=ad->getClose();
    priority_queue<Bid> bids=ad->getBids();
	int num_bids=bids.size();
   string bid_email="";
   float bid_amount=0;
   int bid_quantity=0;
   int currentwin_quantity=0;
   int notbidon_quantity=0;
	Client* client=users[ad->getEmail()];
	string fname=client->getFname();
	string lname=client->getLname();
	oss<<"<br>"<<"The first name of the seller is:"<<fname<<endl;
    oss<<"<br>"<<"The last name of the seller is:"<<lname<<endl;
	oss<<"<br>"<<"The posting date of the advertisement is:"<<start<<endl;
    oss<<"<br>"<<"The closing date of the advertisement is:"<<close<<endl;
	oss<<"<br>"<<"The quantity of items in this advertisement is:"<<total_quantity<<endl;
	oss<<"<br>"<<"The total number of bids placed on this advertisement is:"<<num_bids<<endl;
	oss<<"<br>"<<"------------------------------------------------------------"<<endl;
	if (total_quantity==1&&!bids.empty())
	{
		Bid top_bid=bids.top();
		float amount=top_bid.getAmount();
		string email=top_bid.getEmail();
		oss<<"<br>"<<"The dollar amount of the highest bid is:"<<amount<<endl;
		oss<<"<br>"<<"The email address of the user who has placed the highest bid is:"<<email<<endl;
	}
	else if(total_quantity>1)
	{    int quantity=0;
		vector<Bid> win_bids=ad->getTopDutchBids();
        vector<Bid>::iterator itr_bids;
        for (itr_bids=win_bids.begin();itr_bids!=win_bids.end();itr_bids++)
		{
			bid_email=itr_bids->getEmail();
			bid_amount=itr_bids->getAmount();
			bid_quantity=itr_bids->getQuantity();
			quantity=quantity+bid_quantity;
            if (quantity<=total_quantity)
			{
				currentwin_quantity=bid_quantity;
            }
			else if (quantity>total_quantity)
			{
				quantity=quantity-bid_quantity;
				currentwin_quantity=total_quantity-quantity;
				quantity=quantity+bid_quantity;
			}
        oss<<"<br>"<<"The bidder's email address is:"<<bid_email<<endl;
		oss<<"<br>"<<"The dollar amount of the bid is:"<<bid_amount<<endl;
		oss<<"<br>"<<"The number of items bid on is:"<<bid_quantity<<endl;
		oss<<"<br>"<<"The number of items that the bid is currently winning is:"<<currentwin_quantity<<endl;
		oss<<"<br>"<<"------------------------------------------------------------"<<endl;
		}
		if (quantity<total_quantity)  notbidon_quantity=total_quantity-quantity;
		else if (quantity>=total_quantity) notbidon_quantity=0;
        oss<<"<br>"<<"The amount of items in the advertisement that have not been bid on is:"<<notbidon_quantity<<endl;
	}
}

⌨️ 快捷键说明

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