📄 plane.h
字号:
enum Plane_status {null, arriving, departing};
class Plane
{
public:
Plane( );
Plane(int flt, int time, Plane_status status);
void refuse( ) const;
void land(int time) const;
void fly(int time) const;
int started( ) const { return clock_start; }
private:
int flt_num;
int clock_start;
Plane_status state;
};
Plane::Plane(int flt, int time, Plane_status status)
/* Post: The Plane data members flt num, clock_start , and state are set to the
values of the parametersflt ,time andstatus , respectively. */
{
flt_num=flt;
clock_start = time;
state = status;
cout<<" Plane number "<<flt<<" ready to ";
if(status==arriving)
cout<<"land."<<endl;
else
cout<<"take off."<<endl;
}
Plane::Plane( )
/* Post: The Plane data membersflt num,clock_start ,state are set to illegal default
values. */
{
flt_num=-1;
clock_start =-1;
state=null;
}
void Plane::refuse( ) const
/* Post: Processes a Plane wanting to use Runway, when the Queue is full. */
{
cout<<" Plane number "<<flt_num;
if(state==arriving)
cout<<" directed to another airport"<<endl;
else
cout<<" told to try to takeoff again later"<<endl;
}
void Plane::land(int time) const
/* Post: Processes aPlane that is landing at the specied time. */
{
int wait = time-clock_start;
cout<<time<<": Plane number "<<flt_num << " landed after ";
cout<<wait<<" time unit"<<((wait==1) ? "" : "s");
cout<<" in the takeoff queue." << endl;
}
void Plane::fly(int time) const
/* Post: Process aPlane that is taking off at the specied time. */
{
int wait = time-clock_start;
cout<<time << ": Plane number " << flt_num << " took off after ";
cout<<wait<<" time unit"<< ((wait == 1) ? "" : "s");
cout<<" in the takeoff queue."<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -