📄 truck.cpp
字号:
// Truck.cpp: implementation of the CTruck class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "garage.h"
#include "Truck.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
//#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CTruck *CTruck::p_free=NULL;
int CTruck::getCharge(){
COleDateTimeSpan timespan(0,0,1,0);
timespan=COleDateTime::GetCurrentTime()-inTime;
int fee=(timespan.GetDays()*24*2+timespan.GetHours()*2)*unitPrice;
if(timespan.GetMinutes()>0||timespan.GetSeconds()>0)
fee+=(timespan.GetMinutes()/30+1)*unitPrice;
return fee+keepFee;
}
void *CTruck::operator new(size_t size)
{
CTruck * p;
if(p_free==NULL)
{
p_free=(CTruck*)new char[size*NUM3];
for(p=p_free;p!=p_free+NUM3-1;p++)
p->next=p+1;
p->next=NULL;
}
p=p_free;
p_free=p_free->next;
memset(p,0,size);
return p;
}
void CTruck::operator delete(void *p)
{
((CTruck*)p)->next=p_free;
p_free=(CTruck*)p;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -