rail_vehicle.h
来自「Silmulation of connecting trains」· C头文件 代码 · 共 94 行
H
94 行
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 + =
减小字号Ctrl + -
显示快捷键?