serverfun.cpp

来自「模拟银行(也可以其他类似)一天的营运光顾情况。」· C++ 代码 · 共 61 行

CPP
61
字号
#include"servertype.h"
#include<iomanip>
#include<iostream>
using namespace std;

SErverType::SErverType()
{
	strcpy(status,"free");
	transactiontime=0;
}

bool SErverType::ServerIsFree()
{
	if(!strcmp(status,"free"))return true;
	else return false;
}

bool SErverType::ServerIsBusy()
{
	if(strcmp(status,"busy")==0)return true;
	else return false;
}

void SErverType::SetFree()
{
	strcpy(status,"free");
}

void SErverType::SetBusy()
{
	strcpy(status,"busy");
}

void SErverType::DecreaseTransactionTime()//客户一离开,应该输出离开信息
{
	transactiontime=transactiontime-1;
	if(transactiontime==0)
	{
		SetFree();
		currentcustomer.DepartureDisplay();
	}
}


void SErverType::GetCustomer(CUstomerType cust)//客户一来到服务器,应该输出开始服务的信息
{
	if(strcmp(status,"free")==0)
	{
		currentcustomer=cust;
		transactiontime=currentcustomer.GetTransactionTime();
		SetBusy();
		currentcustomer.StartServerDisplay();
	}
	else
	return;
}

int SErverType::GetTraTime()
{
	return transactiontime;
}

⌨️ 快捷键说明

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