必须用方法和数组来完成,练习题 [英] has to be done with methods and arrays, practice question

查看:85
本文介绍了必须用方法和数组来完成,练习题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

游戏以逗号分隔的顺序文件scores.txt维护其玩家的分数,其中记录结构如下所述。



示例文件。它包含以下样本数据:



G001,Hot Shot,280

G002,Loose Cannon,650

G003,FireFox,720

G004,Foxxy,100



scores.txt记录结构

字段名称类型

玩家编号字符串

玩家名字符串

分数整数













菜单驱动程序需要用户创建报告, /或搜索文件..



菜单格式



游戏菜单



1.玩家报告

2.搜索玩家

3.分数分析

4.退出



用户应能够随时创建报告,搜索和分数分析。选择退出时程序将终止。





报告格式(样本数据)



玩家姓名分数引用



Hot Shot 280 Sluggish Snail

Loose Cannon 650 Bobbing Bobcat

Fire Fox 720 Rocketing Rabbit

Foxxy 100 Sluggish Snail





平均分数575

顶级玩家FireFox









除了得分,你必须为每个玩家显示相应的引用,使用下表做确定引用。

表1

分数引用

减去超过400 Sluggish Snail

介于400和599之间Ambling Armadeillo

介于600和699之间Bobbing Bobcat

介于700和999之间的Rocketing Rabbit

大于999 TurboCharged Cheetah









< br $>
搜索

允许用户输入玩家编号,然后程序将搜索文件,并显示玩家姓名和所选玩家的分数。如果找不到播放器,则会显示一条消息,指出找不到匹配项。



示例对话

输入玩家编号:G002



玩家姓名:松散的大炮



得分:650







分数分析

需要一份报告,显示在上述范围内得分的球员数量。使用数组存储每个范围内的数字。



此范围内的范围数

0-399 2

400-599 0

600-699 1

700-999 1

1000及以上0

A Game maintains scores for its players in a comma delimited sequential file "scores.txt" with the record structure outlined below.

An example file. It contains the following sample data:

G001,Hot Shot,280
G002,Loose Cannon,650
G003,FireFox,720
G004,Foxxy,100

scores.txt record structure
Field Name Type
Player Number String
PlayerName String
Score Integer






A menu driven program is required the user create an report and/or search the file..

Menu Format

Game Menu

1. Player Report
2. Search for a Player
3. Score Analysis
4. Exit

The user shall be able to create report, search and do score analysis as often as they like. The program will terminate when exit is selected.


Report Format (for sample data)

Player Name Score Citation

Hot Shot 280 Sluggish Snail
Loose Cannon 650 Bobbing Bobcat
Fire Fox 720 Rocketing Rabbit
Foxxy 100 Sluggish Snail


Average Score 575
Top Player FireFox




Alongside the score, you must display the appropriate citation for each player, use the table below do to determine the citation.
Table 1
Score Citation
Less than 400 Sluggish Snail
between 400 and 599 Ambling Armadeillo
Between 600 and 699 Bobbing Bobcat
Between 700 and 999 Rocketing Rabbit
Greater than 999 TurboCharged Cheetah





Search
Allow the user enter a player number, the program will then search the file, and display the players name, and the score for chosen player. If the player is not found display a message stating "No match found".

Example dialogue
Enter Player Number: G002

Player name : Loose Cannon

Score : 650



Score Analysis
A report showing the number of players that score in the above ranges is required. Use an array to store the number in each range.

Range Number in this range
0-399 2
400-599 0
600-699 1
700-999 1
1000 and over 0

推荐答案

最好是做自己的功课。这是给你的,这样你就可以学到一些东西,想想所教的内容。阅读你的教科书并尝试一下。



一旦你有代码并遇到问题,你可以随时回到这里,提出更具体的问题,社区将做最好的帮助你。不要忘记仅发布造成问题的相关代码位,因为代码转储通常对帮助/协助您没有帮助。



祝你好运,编码愉快。
It would be best if you did your own homework. It is given to you so that you will learn something, think about what have been taught. Read your text books and give it a try.

Once you have code and run into problems you can always come back here with a more specific question and the community will do its best to help you. Don''t forget to post only the relevant code bits that pose the problem as a code dump is not usually helpful at all in getting someone to help/assist you.

Good luck and happy coding.


这篇关于必须用方法和数组来完成,练习题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆