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

📄 cbus.h

📁 用VC++编程
💻 H
字号:
#ifndef CBUS
#define CBUS

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <math.h>
#include <Windows.h>

using namespace std;

#define TOXA	0
#define TOBJ	1
#define DIRS	2

#define BUSTYPES	2
#define TYPE_W		0
#define TYPE_Y		1

#define TOTLE_DISTANCE	  174
#define CITYS			  7

#define TIME2INT(m,s)	(m*60+s)
#define	INT2STIME(t)	printf("%2d:%02d",t/60,t%60);

class CBustype
{
public:
	string m_typename;//车型名称
	double m_velocity;//车速
	int	   m_limit;		   //限载人数
	CBustype(string nametype,double velocity,int limit);/// 构造函数
}; 
class CBus;

class CPassenger
{
public:
	int m_atime;	/// 侯车时间
	int m_add;		/// 目的地
	CPassenger(int atime,int add);/// 构造函数
};

class CStation;

class CBus
{
public:
	int m_no;	//编号
	int m_type;	//车型
	int m_stime;//发车时间
	int m_dir;	//方向
	CStation *m_from, *m_to;//始发地,目的地

	int m_x,m_y;

	vector<CPassenger> m_passenger;////容器
	CBus(int no,int type,CStation *from,CStation *to,int stime,int dir,int x,int y);/// 构造函数
	void Move();
};

class CStation
{
public:
	vector<CBus *> m_bus;
	vector<CPassenger> m_wait;
	CString	m_name;

	int		m_stime[BUSTYPES],m_etime[BUSTYPES];//起止时间
	int		m_interval[BUSTYPES];				//发车间隔
	int		m_ntime[BUSTYPES];					//下一趟进站车的发车时间
	int		m_ltime;					//最后一班车发车时间
	int		m_nstime;					//下一次发车时间
	double 	m_p[CITYS];					//目的地概率
	int		m_x,m_y;

	CCriticalSection m_cirtical;

	~CStation();
	void Init(CString name,int x,int y,
			  int stime[BUSTYPES],int etime[BUSTYPES],int interval[BUSTYPES],
			  double p[CITYS]);
	void Arrive(CBus *bus);
	void AppendBus(int num,CStation *to,int type,int dir,int x,int y);
	void Start();	//发车
	void Wait();    ///等待
	void DrawBus();////显示车
	void DrawInfo();////显示车上信息
};

extern int g_stime,g_etime;//模拟过程起始时间
extern int g_ctime;		//当前时间
extern int g_runbus;		//运行的汽车数量
extern HICON g_icon[2];

UINT MainThread(LPVOID lparam);
UINT BusMoveThread(LPVOID lparam);
void DrawI(int ox,int oy,int nx,int ny,int icon);
void DrawT(int ox,int oy,int nx,int ny,CString str);
void DrawT(int ox,int oy,int nx,int ny,int num,int flag=0);

#endif

⌨️ 快捷键说明

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