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

📄 rail_vehicle.h

📁 Silmulation of connecting trains
💻 H
字号:
using namespace std;

class RailVehicle
{
private:

protected:
	RailVehicle *front;
	RailVehicle *back;
	int typeOfVehicle;
	

public:	
	//RailVehicle();
	RailVehicle* getFirst();
	RailVehicle* connectToNext( RailVehicle * );
	int getSpeed();
	void showAll( ostream&);
	int getMassAll();
	
	virtual ~RailVehicle();
	virtual void showThis( ostream&)const = 0;
	virtual int getMassThis()const = 0;

};

class Engine : public  RailVehicle
{
private:
	int mass,
	    maxSpeed,
	    maxWeight,
	    currentSpeed;

public:

	Engine(int, int, int);
	~Engine();
	int checkMaxSpeedAvailable();
	void changeSpeed(int );
	int getMaxWeight();
	int getCurrentSpeed();	
	int getMaxSpeed();	
	void showThis(ostream &)const;
	virtual int getMassThis()const;
};

class Cargo
{
private:

	Cargo * cargoPtr;
public:
	int 	mass;
	string 	name;
	Cargo 	*nextCargo;
	RailVehicle 	*car;

	Cargo(string, int);
	~Cargo();
	int getMassThis();
	Cargo* findLastCargo( Cargo * );
};
class FreightCar : public RailVehicle
{
private:
	int 	mass;
	Cargo 	*cargoPtr;

public:
	
	FreightCar(int);
	~FreightCar();
	void addFreight(Cargo *);
	Cargo * removeFreight();
	
	virtual int getMassThis()const;
	void showThis(ostream &)const;
	void showCargo(ostream &);
};


class MyException

{
public:	
	string msg;
	MyException(string msg_)
	{
		msg = msg_;
	}
};

⌨️ 快捷键说明

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