Problem C: 小型飞机大战
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 851 Solved: 712
[Submit][Status][Web Board]
Description
飞机大战这个小游戏很好玩,作为一名编程狂人,自己不去写个好玩的游戏,怎么能说得过去呢?
现在,请使用C++来编写一个小的飞机大战游戏雏形,至少包括如下类:
1. FlyThing类:敌机和战机的父类,是一个抽象类。
(1)拥有名字属性和位置属性,其中名字是一个字符串,位置是二维空间下的坐标,代表了在屏幕上的位置。
(2)纯虚函数void fly(),模拟飞机的飞行动作。
(3)void show():显示飞机的名字和位置。格式为:“$ at x y”,其中$为飞机名字,x和y是横坐标和纵坐标。
(4)其他必要的函数。
2. EnemyPlane类:敌机类,是FlyThing的子类。其Fly()函数实现将飞机的纵坐标加1。
3. MyPlane类:战机类,是FlyThing的子类。其Fly()函数根据输入实现飞行。具体是:
(1)如果输入A或a,则横坐标减1;
(2)如果输入S或s,则纵坐标加1;
(3)如果输入W或w,则纵坐标减1;
(4)如果输入D或d,则横坐标加1。
Input
第1行N是一个正整数,之后N行,每行包括1个字符串、2个整数分别是敌机名字和横、纵坐标。
第N+2行是一个正整数M,之后M行每行是一个字符,为a、s、d、w之一,用于战机的飞行。
Output
见样例~
Sample Input
3enemy1 10 0enemy2 20 20enemy3 30 104aswd
Sample Output
WUDI at 50 50enemy1 at 10 0enemy2 at 20 20enemy3 at 30 10WUDI at 49 50enemy1 at 10 1enemy2 at 20 21enemy3 at 30 11WUDI at 49 51enemy1 at 10 2enemy2 at 20 22enemy3 at 30 12WUDI at 49 50enemy1 at 10 3enemy2 at 20 23enemy3 at 30 13WUDI at 50 50enemy1 at 10 4enemy2 at 20 24enemy3 at 30 14
HINT
Append Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|