Skip to main content
A-LevelComputer ScienceFurther programming9618/41 · Oct/Nov 2022 · Q231 Marks

A computer program is being developed that uses a set of cards. The program is written using object-oriented programming. The program has two classes: Card and Hand. The methods and attributes of these classes are shown: Card Number: INTEGER stores the card number from 1 to 5 inclusive Colour : STRING stores the card colour: red, blue or yellow Constructor() takes a number and colour as parameters and sets the private values to these parameters GetNumber() returns the card number GetColour() returns the card colour Hand Cards : ARRAY[0:9] OF Card 1D array of type Card FirstCard : INTEGER stores the position of the first card in the hand NumberCards : INTEGER stores the number of cards in the hand Constructor() takes five card objects as parameters, assigns each card to the array Cards[], initialises FirstCard to 0 and NumberCards to 5 GetCard() takes an index as a parameter and returns the card at that index in the array

  1. (a)(i)Write program code to declare the class Card, its attributes and constructor. Do not write program code for the get methods. Use your programming language appropriate constructor. All attributes must be private. If you are writing in Python, include attribute declarations using comments.[5]
  2. (a)(ii)Write program code for the class methods GetNumber() and GetColour().[3]
  3. (a)(iii)The program is tested with the following cards: Number | Colour ---|--- 1 | red 2 | red 3 | red 4 | red 5 | red 1 | blue 2 | blue 3 | blue 4 | blue 5 | blue 1 | yellow 2 | yellow 3 | yellow 4 | yellow 5 | yellow Write program code to declare each of these cards as a variable of type Card in the main program.[2]
  4. (b)(i)Write program code to declare the class Hand, its attributes and constructor. Do not write the get methods. Use your programming language appropriate constructor. All attributes must be private. If you are writing in Python, include attribute declarations using comments.[6]
  5. (b)(ii)The get method GetCard() takes an index as a parameter and returns the card stored at that index in the array. Write program code for the method GetCard().[2]
  6. (b)(iii)Two players are declared with 5 cards each. Player 1 has the cards: 1 red, 2 red, 3 red, 4 red, 1 yellow. Player 2 has the cards: 2 yellow, 3 yellow, 4 yellow, 5 yellow, 1 blue. Write program code to declare player 1 and player 2 as objects of type Hand, with the cards indicated.[2]
  7. (c)(i)The function CalculateValue() takes a player's hand as a parameter and returns a score calculated using the following rules: • If a card is red, 5 points are added to the player's score. • If a card is blue, 10 points are added to the player's score. • If a card is yellow, 15 points are added to the player's score. • The number of each card in the hand is added to the player's score. Write program code for the function CalculateValue(). Assume that there are only 5 cards in the player's hand in this function.[6]
  8. (c)(ii)Amend the main program by writing program code to use the function CalculateValue() for each of the two players. The player with the highest score wins. Output an appropriate message to identify the winning player, or if the game was a draw (both players have the same number of points).[4]
  9. (c)(iii)Test your program. Take a screenshot to show the output. Copy and paste the screenshot into part 2(c)(iii) in the evidence document.[1]

Mark scheme

Marking points from the official mark scheme (Oct/Nov 2022). The mark or mark type is shown in brackets.

  1. 1 mark per point:
  2. [1] class Card declaration (and end where appropriate)
  3. [1] Private attributes declared Number as integer and Colour as string
  4. [1] constructor header (and end where appropriate)...
  5. [1] ...taking 2 parameters
  6. [1] assigning parameters to attributes
  7. 1 mark per point:
  8. [1] 1 get method as function (and end where appropriate) with no parameters...
  9. [1] ...returning the value
  10. [1] 2nd correct get method
  11. 1 mark per point:
  12. [1] one card initialised as type Card
  13. [1] all 15 cards initialised correctly as type Card
  14. 1 mark per point:
  15. [1] class Hand declaration (and end where appropriate)
  16. [1] private attribute declarations; FirstCard as integer, NumberCards as integer
  17. [1] private attribute array named Cards of type Card with 10 elements
  18. [1] constructor with 5 Card objects as parameters
  19. [1] assigning each Card parameter to the array (in constructor)
  20. [1] initialising FirstCard to 0 and NumberCards to 5 (in constructor)
  21. 1 mark per point:
  22. [1] function GetCard() header (and end where appropriate) taking (integer) parameter
  23. [1] returning the card at parameter index in array
  24. 1 mark per point:
  25. [1] 2 variables (player 1 and player 2) of type Hand
  26. [1] using constructor and sending the correct variables as parameters
  27. 1 mark per point:
  28. [1] function CalculateValue() header (and end where appropriate) taking one parameter and initialising score to 0
  29. [1] looping through all 5 Card objects in parameter array...
  30. [1] adding 5 to score for red, 10 to score for blue, 15 to score if yellow
  31. [1] adding each card number to score
  32. [1] Using GetCard(),GetColour() and GetNumber() correctly
  33. [1] Returning calculated score
  34. 1 mark per point:
  35. [1] One function call of CalculateValue()for each player
  36. [1] ...sending the player's hand as parameter
  37. [1] Comparing return values and outputting the player with the highest score in an appropriate message
  38. [1] ... or if there was a draw in appropriate message
  39. [1] Output showing player 2 wins, for example:

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Further programming, A-Level Computer Science (syllabus 9618). Structured question, 31 marks.
Source
A-Level Computer Science, Oct/Nov 2022 Paper 4 Variant 1, question 2.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep