College.h
上传用户:wszmarenbt
上传日期:2013-04-26
资源大小:2552k
文件大小:5k
源码类别:

Windows编程

开发平台:

Visual C++

  1. //THE CLASSES AND SUBCLASSES OF A COLLEGE
  2. //FILE COLLEGE.H
  3. #include <iostream.h>
  4. #include   <string.h>
  5. #include    <conio.h>
  6. const char EMPTY='';
  7. class RECORD
  8. {
  9. private :
  10. char *NAME;
  11. char *SEX;
  12. char *IDENTIFIER;
  13. char *BIRTHDAY;
  14. char *ADDRESS;
  15. int  AGE;
  16. public :
  17. RECORD()
  18. {
  19. NAME=EMPTY;
  20. SEX="MALE";
  21. IDENTIFIER=EMPTY;
  22. BIRTHDAY=EMPTY;
  23. ADDRESS=EMPTY;
  24. AGE=0;
  25. }
  26. void INSERT_NAME(char *S)
  27. {
  28. char *BUFFER;
  29. BUFFER=new char[strlen(S)+1];
  30. strcpy(BUFFER,S);
  31. NAME=BUFFER;
  32. }
  33. void INSERT_SEX(char *S)
  34. {
  35. char *BUFFER;
  36. BUFFER=new char[strlen(S)+1];
  37. strcpy(BUFFER,S);
  38. SEX=BUFFER;
  39. }
  40. void INSERT_IDENTIFIER(char *S)
  41. {
  42. char *BUFFER;
  43. BUFFER=new char[strlen(S)+1];
  44. strcpy(BUFFER,S);
  45. IDENTIFIER=BUFFER;
  46. }
  47. void INSERT_BIRTHDAY(char *S)
  48. {
  49. char *BUFFER;
  50. BUFFER=new char[strlen(S)+1];
  51. strcpy(BUFFER,S);
  52. BIRTHDAY=BUFFER;
  53. }
  54. void INSERT_ADDRESS(char *S)
  55. {
  56. char *BUFFER;
  57. BUFFER=new char[strlen(S)+1];
  58. strcpy(BUFFER,S);
  59. ADDRESS=BUFFER;
  60. }
  61. void INSERT_AGE(int A)
  62. {
  63. AGE=A;
  64. }
  65. void PRINT()
  66. {
  67. cout<<"n"<<NAME<<"n"
  68. <<SEX<<"   "<<IDENTIFIER<<"   "<<BIRTHDAY<<"   "<<AGE<<"n"<<ADDRESS;
  69. }
  70. };
  71. class STUDENT : public RECORD
  72. //This class is derived from RECORD and inherits all the public members of
  73. //the parent class
  74. {
  75. private :
  76. char *STUDENT_ID;
  77. char *DORMITORY_NUM;
  78. char *MAJOR;
  79. int LEVEL;
  80. public :
  81. STUDENT()
  82. {
  83. RECORD:RECORD(); //Use the same constructor as
  84.   //the parent class.
  85. DORMITORY_NUM=EMPTY;
  86. MAJOR=EMPTY;
  87. LEVEL=0;
  88. }
  89. void INSERT_STUDENT_ID(char *S)
  90. {
  91. char *BUFFER;
  92. BUFFER=new char[strlen(S)+1];
  93. strcpy(BUFFER,S);
  94. STUDENT_ID=BUFFER;
  95. }
  96. void INSERT_DORMITORY_NUM(char *S)
  97. {
  98. char *BUFFER;
  99. BUFFER=new char[strlen(S)+1];
  100. strcpy(BUFFER,S);
  101. DORMITORY_NUM=BUFFER;
  102. }
  103. void INSERT_MAJOR(char *S)
  104. {
  105. char *BUFFER;
  106. BUFFER=new char[strlen(S)+1];
  107. strcpy(BUFFER,S);
  108. MAJOR=BUFFER;
  109. }
  110. void INSERT_LEVEL(int A)
  111. {
  112. LEVEL=A;
  113. }
  114. void PRINT()
  115. {
  116. RECORD::PRINT();
  117. cout<<"nSTUDENT_ID - - >"<<STUDENT_ID;
  118. cout<<"nDORMITORY_NUM"<<DORMITORY_NUM;
  119. cout<<"nMAJOR - - >"<<MAJOR;
  120. cout<<"nLEVEL - - >"<<LEVEL;
  121. }
  122. };
  123. class STAFF : public RECORD
  124. //This class is derived from RECORD and inherits all the public members
  125. //of the parent class.
  126. {
  127. private :
  128. char *DEPARTMENT;
  129. int   WORKTIME;
  130. float SALARY;
  131. public :
  132. STAFF()
  133. {
  134. RECORD:RECORD(); //Use the same constructor as
  135.   //the parent class.
  136. DEPARTMENT=EMPTY;
  137. WORKTIME=0;
  138. SALARY=300;
  139. }
  140. void INSERT_DEPARTMENT(char *S)
  141. {
  142. char *BUFFER;
  143. BUFFER=new char[strlen(S)+1];
  144. strcpy(BUFFER,S);
  145. DEPARTMENT=BUFFER;
  146. }
  147. void INSERT_SALARY(float A)
  148. {
  149. SALARY=A;
  150. }
  151. void INSERT_WORKTIME(int A)
  152. {
  153. WORKTIME=A;
  154. }
  155. void PRINT()
  156. {
  157. RECORD::PRINT();
  158. cout<<"nDEPARTMENT - - >"<<DEPARTMENT
  159. <<"nWORK TIME (PER DAY) - - >"<<WORKTIME
  160. <<"nSALARY - - > $"<<SALARY;
  161. }
  162. };
  163. class PROFESSOR : public STAFF
  164. //This class is derived from the derived class STAFF.
  165. {
  166. private:
  167. char *TEACH_MAJOR;
  168. char *SEARCH_NAME;
  169. int   GRADUATE_STUDENT_NUM;
  170. public :
  171. PROFESSOR()
  172. {
  173. STAFF:STAFF();
  174. TEACH_MAJOR=EMPTY;
  175. SEARCH_NAME=EMPTY;
  176. GRADUATE_STUDENT_NUM=0;
  177. }
  178. void INSERT_TEACH_MAJOR(char *S)
  179. {
  180. char *BUFFER;
  181. BUFFER=new char[strlen(S)+1];
  182. strcpy(BUFFER,S);
  183. TEACH_MAJOR=BUFFER;
  184. }
  185. void INSERT_SEARCH_NAME(char *S)
  186. {
  187. char *BUFFER;
  188. BUFFER=new char[strlen(S)+1];
  189. strcpy(BUFFER,S);
  190. SEARCH_NAME=BUFFER;
  191. }
  192. void INSERT_GRA_NUM(int A)
  193. {
  194. GRADUATE_STUDENT_NUM=A;
  195. }
  196. void PRINT()
  197. {
  198. STAFF::PRINT();
  199. cout<<"nTEACH MAJOR - - >"<<TEACH_MAJOR;
  200. cout<<"nTHE PROFESSOR'S SEARCH'S NAME - - >"<<SEARCH_NAME;
  201. cout<<"nTHE NUMBER OF PROFESSOR'S GRADUATE STUDENT"<<GRADUATE_STUDENT_NUM;
  202. }
  203. };
  204. class WORKER:public STAFF
  205. //This class is derived from the derived class STAFF.
  206. {
  207. private:
  208. char *WORK_TYPE;
  209. public:
  210. WORKER()
  211. {
  212. STAFF:STAFF();
  213. WORK_TYPE="WORKER";
  214. }
  215. void INSERT_WORK_TYPE(char *S)
  216. {
  217. char *BUFFER;
  218. BUFFER=new char[strlen(S)+1];
  219. strcpy(BUFFER,S);
  220. WORK_TYPE=BUFFER;
  221. }
  222. void PRINT()
  223. {
  224. STAFF::PRINT();
  225. cout<<"nTHE WORKER IS A - - >"<<WORK_TYPE;
  226. }
  227. };