12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

112 Day 4<br />

List<strong>in</strong>g 4.2. cont<strong>in</strong>ued<br />

59: case MSG_TAKEOFF : {<br />

60: // Can’t take off if already <strong>in</strong> the air!<br />

61: if (status != ONRAMP) {<br />

62: strcpy(response, “I’m already <strong>in</strong> the air!”);<br />

63: return false;<br />

64: }<br />

65: TakeOff(dir);<br />

66: break;<br />

67: }<br />

68: case MSG_CHANGE : {<br />

69: // Can’t change anyth<strong>in</strong>g if on the ground.<br />

70: if (status == ONRAMP) {<br />

71: strcpy(response, “I’m on the ground”);<br />

72: return false;<br />

73: }<br />

74: // Only change if a non-negative value was passed.<br />

75: if (spd != -1) speed = spd;<br />

76: if (dir != -1) head<strong>in</strong>g = dir;<br />

77: if (alt != -1) altitude = alt;<br />

78: status == CRUISING;<br />

79: break;<br />

80: }<br />

81: case MSG_LAND : {<br />

82: if (status == ONRAMP) {<br />

83: strcpy(response, “I’m already on the ground.”);<br />

84: return false;<br />

85: }<br />

86: Land();<br />

87: break;<br />

88: }<br />

89: case MSG_REPORT : ReportStatus();<br />

90: }<br />

91: //<br />

92: // Standard reponse if all went well.<br />

93: //<br />

94: strcpy(response, “Roger.”);<br />

95: return true;<br />

96: }<br />

97: //<br />

98: // Perform takeoff.<br />

99: //<br />

100: void<br />

101: Airplane::TakeOff(<strong>in</strong>t dir)<br />

102: {<br />

103: head<strong>in</strong>g = dir;<br />

104: status = TAKINGOFF;<br />

105: }<br />

106: //<br />

107: // Perform land<strong>in</strong>g.<br />

108: //<br />

109: void<br />

110: Airplane::Land()<br />

111: {

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!