回分類題庫
d230: 101OOP Lab Exercise: Virtual function
出處:

Difficulity : N/A
Accepted : 40 Times | Submit :95 Times | Clicks : 1260
Accepted : 38 Users | Submit : 40 Users | Accepted rate : 95%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2012-12-10 17:19

Content :

There are ten position that only used for human.

Human can stay at the position 1~10.

If human stay at the position, it need to record the human's sex and age.

Human also can leave the position.

 

There are three class that you have to implement.

1.      Class Human

Record the age of the human and you can get the human age from this class.

2.      Class Girl

Inheritance of Class Human

3.      Class Boy

Inheritance of Class Human

 

All of the classes have a print() function which prints the state of object.

For example, if an object points to the Girl and it will print “Girl   ”.

And if an object points to the Human and it will print “Nobody ”.

You need to apply the virtual function to implement this exercise.

Input :

There are three commands for the test.

1. print

2. girl/boy position age

3. leave position

4. quit

Output :

Sample Input :

print
girl 1 11
boy 2 22
girl 3 33
boy 4 44
girl 5 55
boy 6 66
girl 7 77
boy 8 88
girl 9 99
boy 10 100
print
leave 5
leave 9
print
quit

Sample Output :

====Sex====Age===
1.  Nobody 0
2.  Nobody 0
3.  Nobody 0
4.  Nobody 0
5.  Nobody 0
6.  Nobody 0
7.  Nobody 0
8.  Nobody 0
9.  Nobody 0
10. Nobody 0
=================
====Sex====Age===
1.  Girl   11
2.  Boy    22
3.  Girl   33
4.  Boy    44
5.  Girl   55
6.  Boy    66
7.  Girl   77
8.  Boy    88
9.  Girl   99
10. Boy    100
=================
====Sex====Age===
1.  Girl   11
2.  Boy    22
3.  Girl   33
4.  Boy    44
5.  Nobody 0
6.  Boy    66
7.  Girl   77
8.  Boy    88
9.  Nobody 0
10. Boy    100
=================

Hint :


  

Author :

(管理員:oop10101)

  Solve it!   Status Forum (0)

C++
C
JAVA
43989. oop100703031 (6 ms , 424KB)
42970. oop100703014 (6 ms , 438KB)
42968. oop100703013 (6 ms , 428KB)
42963. oop100703048 (6 ms , 432KB)
42893. oop100703016 (6 ms , 436KB)
沒有解題記錄 55128. nwgs524513cja (104 ms , 404KB)

執行時間會受很多因素影響因此僅供參考,主機等級請看這裡