ExamBank Scot · Higher Computing Science question bank · All Higher Computing Science questions
12 marks · Design notations and data flow
At the end of each week, the player with the highest score is rewarded with an upgrade to one of their three attributes. If more than one player has the same score, then the player who has been playing for the shortest time is rewarded. The design for this part of the program is shown below. Find player to upgrade Loop for Return position of Initialise each player highest score variables Is current score > highest score? Yes Set position to current index Explain why a program produced from this design would not be fit for purpose. The game stores the following details for each player: • unique ID • score • the number of minutes they have played the game • speed • strength • agility. A sample of data is shown below. … Zodiac83, 547063, 361.45, 17, 19, 13 Thrasher05, 176491, 175.12, 15, 25, 14 Knuckles45, 92543, 63.42, 16, 14, 21 … Using a programming language of your choice, define a suitable record data structure to store the data. There are currently 10 000 registered players in the game. Using a programming language of your choice, declare a variable that can store the data for the 10 000 players. Your answer should include the record data structure defined in part (i). All players whose playing time is over 500 minutes will have their speed increased by 3. Using a programming language of your choice, write the code to implement this. Your answer should use the record data structure from part (b) (i). The program is implemented using sub‑programs to help to make the code maintainable. Describe two other benefits of creating modular code. As part of the program’s comprehensive test plan each sub‑program was tested individually. Describe one benefit of having a comprehensive test plan. An online game stores a player’s unique ID, their total score and the number of minutes they have played the game. The game also stores three attributes for the player which are speed, strength and agility. Throughout gameplay the player’s score and playing time are updated. Zodiac83 Score – 547063 Playing time – 361.45 minutes Speed – 17 Strength – 19 Agility – 13
Design does not account for the same score(shortest time). • record declaration • 6 appropriate fields within a record 1 mark for each bullet RECORD player IS {STRING uniqueID, INTEGER score, REAL minutes, INTEGER speed, INTEGER strength, INTEGER agility} Do not award second mark if an incorrect data type has been applied to a field. • array of (10 000) records • using data structure from (i) 1 mark for each bullet DECLARE allPlayers AS array of player INITIALLY [NULL] *10 000 • loop for length of array/10 000 iterations • IF current minutes >500 • increase current speed by 3 • correct use of array name and field names 1 mark for each bullet For ‘current’ must reference array position. Award mark for ‘current’ if array is referenced without record structure. FOR index FROM 0 TO 9 999 DO IF allPlayers[index].minutes>500 THEN allPlayers[index].speed= allPlayers[index].speed+3 END IF END FOR • modules can be reused. • each part of the solution can be tested independently. • errors are easier to locate. • different programmers can code different modules (independently). • variables only in memory during execution of subroutine. • limits accessibility of local variables. 1 mark for each bullet Maximum 2 marks • ensures that all (functional) requirements of the program are tested.