翻译:the opening and closing of vessel’s hatches is to be performed by ship’s crew at owner’s expenses.
第1题:
阅读以下说明和C++代码。
【说明】
传输门是传输系统中的重要装置。传输门具有Open(打开)、Closed(关闭)、Opening (正在打开)、StayOpen(保持打开)和Closing(正在关闭)五种状态。触发传输门状态转换的事件有click、complete和timeout三种。事件与其相应的状态转换如下图所示。

下面的C++代码1与C++代码2分别用两种不同的设计思路对传输门进行状态模拟,请填补代码中的空缺。
【C++代码1】
const int CLOSED=1; const int PENING=2;
const int PEN=3; const int CLOSING=4;
const int STAYOPEN=5; //定义状态变量,用不同整数表示不同状态
class Door {
Private:
int state; //传输门当前状态
void setState(int state){ this->state=state;} //设置当前状态
public:
Door():state(CLOSED){};
void getState(){ //根据当前状态输出相应的字符串
switch(state){
case OPENING: cout<<"OPENING"<<endl; break;
case CLOSED: cout<<"CLOSED"<<endl; break;
case OPEN: cout<<"OPEN"<<endl; break;
case CLOSING: cout<<"CLOSING"<<endl; break;
case STAYOPEN:cout<<"STAYOPEN"<<endl; break;
}
};
void click() { //发生click事件时进行状态转换
if ((1)) setState(OPENING);
else if ((2)) setState(CLOSING);
else if ((3)) setState(STAYOPEN);
}
void timeout(){ //发生timeout事件时进行状态转换
if (state == OPEN) setState(CLOSING);
}
void complete(){ //发生complete事件时进行状态转换
if (state == OPENING) setState(OPEN);
else if (state == CLOSING) setState(CLOSED);
}
};
int main(){
Door aDoor;
aDoor.getState();aDoor.click(); aDoor.getState();
aDoor.complete();aDoor.getState(); aDoor.click();
aDoor.getState();aDoor.click(); aDoor.getState(); return 0;
}
【C++代码2】
class Door {
public:
DoorState *CLOSED,*OPENING,*OPEN,*CLOSING,*STAYOPEN,*state;
Door();
virtual~Door(){……//释放申请的内存,此处代码省略);
void setState(DoorState *state) { this->state = state;}
void getState(){
//此处代码省略,本方法输出状态字符串,
//例如,当前状态为CLOSED时,输出字符串为“CLOSED”
};
void click();
void timeout();
void complete();
};
Door::Door(){
CLOSED = new DoorClosed(this); OPENING = new DoorOpening(this);
PEN = new DoorOpen(this); CLOSING = new DoorClosing(this);
STAYOPEN = new DoorStayOpen(this);state = CLOSED;
}
void Door :: click() {(4);)
void Door :: timeout() {(5);)
void Door :: complete() {(6);}
class DoorState//定义一个抽象的状态,它是所有状态类的基类
{
protected:Door *door;
public:
DoorState(Door *door) {this->door = door;}
virtual~DoorState(void);
virtual void click() {}
virtual void complete(
第2题:
请认真阅读以下关于某传输系统的技术说明、状态转换图及C++代码,根据要求回答问题1和问题2。
【说明】
传输门是传输系统中的重要装置。传输门具有Open(打开)、Closed(关闭)、Opening(正在打开)、StayOpen(保持打开)和Closing(正在关闭)5种状态。触发状态的转换事件有click、complete和timeout 3种,事件与其相应的状态转换如图6-18所示。

下面的【C++代码1】与【C++代码2】分别用两种不同的设计思路对传输门进行状态模拟,请填补代码段中的空缺语句。
【C++代码1】
const int CLOSED = 1; const int PENING = 2;
const int PEN = 3; const int CLOSING = 4;
const int STAYOPEN = 5; //定义状态变量,用不同整数表示不同状态
class Door {
private:
private:
int state; //传输门当前状态
void setState(int state) { this->state = stale; } //设置当前状态
public:
Door () :state (CLOSED) { };
void getState() { //根据当前状态输出相应的字符串
switch(state) {
case OPENING: cout <<"OPENING" << endl; break;
case CLOSED: cout << "CLOSED" << endl; break;
case OPEN: cout << "OPEN" << endl; break;
case CLOSING: cout << "CLOSING" << endl; break;
case STAYOPEN: cout << "STAYOPEN" << endl; break;
}
}
void click() { //发生click事件时进行状态转换
if ( (1) ) setState(OPENING);
else if ( (2) ) setState(CLOSING);
else if ( (3) ) setState(STAYOPEN);
}
void timeout() { //发生timeout事件时进行状态转换
if (state == OPEN) setState(CLOSING);
}
void complete() { //发生complete事件时进行状态转换
if (state == OPENING) setState(OPEN);
else if (state == CLOSING) setState(CLOSED);
}
};
int main(){
Door aDoor;
aDoor.getState(); aDoor.click(); aDoor.getState(); aDoor.complete();
aDoor.getState(); aDoor.click(); aDoor.getState(); aDoor.click();
aDoor.getState(); return 0;
}
【C++代码2】
class Door {
public:
DoorState *CLOSED, *OPENING, *OPEN, *CLOSING, *STAYOPEN, *state;
Door();
virtual ~Door() { ... //释放申请的内存,此处代码省略};
void s
第3题:
When loading a tanker,you should ______.
A.load only one tank at a time
B.keep the seamen on watch on standby in the mess room
C.keep a strain on the loading hoses
D.close valves by closing them down,reopening one or two turns,and re-closing
第4题:
第5题:
Using Job Scheduling Console, how can the external successor chain be viewed when a job needs to be canceled?()
第6题:
The work of opening and closing hatches is usually done by crew members.
The work of opening and closing hatch covers is usually done by crew members.
The work of opening hatch covers is usually done by crew members.
The work of closing hatch covers is usually done by crew members.
第7题:
down
out
off
aside
第8题:
Motherboard
Video card
Cutoff switch
AC adapter
第9题:
Exemption space
Tonnage deck
Cofferdam
Tonnage opening
第10题:
closing the window
your closing the window
my closing the window
I closing the window
第11题:
move in an opening direction
move in a closing direction
either open or close
not move at all
第12题:
第13题:
why is quick closing valves important to in engine room machineries ?how are they operated ?
第14题:
The nozzle of a gasoline hose or can should be kept ______.
A.In contact with the fill opening to guard against static spark
B.From making contact with the fill opening to guard against static spark
C.In contact with the fill opening to allow proper venting
D.None of the above
第15题:
第16题:
开关舱的工作通常是由船员来做。()
第17题:
the starting air distributor
the cut-off valve on the air main
the main starting valve
the air bottle control valve
第18题:
using the Hyperbolic Viewer
opening the Impact view and displaying the successors
opening the Job Stream Instance editor for its Job Stream Instance
opening the Dependencies window and drilling down to the successors
第19题:
the ship's officers
the foreman from the shore
the ship's hands
the tally man
第20题:
cleared
checked
removed
repaired
第21题:
later and closing earlier
later and closing later
earlier and closing earlier
earlier and closing later
第22题:
downwards;upwards
upwards;downwards
downwards;downwards
upwards;upwards
第23题:
in contact with the fill opening to guard against static spark
from making contact with the fill opening to guard against static spark
in contact with the fill opening to allow proper venting
None of the above