Skip to main content
A-LevelComputer ScienceFurther programming9618/41 · Oct/Nov 2021 · Q230 Marks

A program, written using object-oriented programming, stores pictures as objects. The program stores the dimensions of the picture (width and height), the colour of the frame (e.g. black), and a description of the picture (e.g. flowers). The class has the following attributes and methods. Description : STRING // stores a description of the picture Width : INTEGER // stores the width e.g. 30 Height : INTEGER // stores the height e.g. 40 FrameColour : STRING // stores the colour e.g. black Constructor() // takes all four values as parameters and sets them to the private attributes GetDescription() // returns the description of the picture GetHeight() // returns the height GetWidth() // returns the width GetColour() // returns the frame colour SetDescription() // takes the new description as a parameter and writes the value to description

  1. (a)The constructor takes the picture description, frame colour, height, and width as parameters and sets these to the private attributes. Write the program code to declare the class Picture and its constructor. Do not write any other methods. Use your language appropriate constructor. All attributes should be private. If you are writing in Python programming language, include attribute declarations using comments. Save your program as question 2. Copy and paste the program code into part 2(a) in the evidence document.[5]
  2. (b)The four get methods return the associated attribute, for example, GetDescription() returns the description of the picture. Write the four get methods. Save your program. Copy and paste the program code into part 2(b) in the evidence document.[3]
  3. (c)The method SetDescription() takes a new description as a parameter, and writes this value to the appropriate attribute. Write the method SetDescription(). Save your program. Copy and paste the program code into part 2(c) in the evidence document.[2]
  4. (d)Write program code to declare an array of type Picture with 100 elements. Save your program. Copy and paste the program code into part 2(d) in the evidence document.[1]
  5. (e)The text file Pictures.txt stores the data for the pictures in the order: description, width, height, colour. For example, for the first picture in the text file: Flowers is the description 45 is the width 50 is the height black is the frame colour. The data read into the program from the text file is stored in an array of type Picture. The main program and the function will need to access the array data. The function ReadData(): • opens the file Pictures.txt • reads the data from the file • creates a new object of type Picture for each picture • writes each object to the array • raises an exception if the file cannot be found • counts and returns the number of pictures in the array. Write program code for the function ReadData(). Save your program. Copy and paste the program code into part 2(e) in the evidence document.[8]
  6. (f)The main program calls the function ReadData(). Write the main program. Save your program. Copy and paste the program code into part 2(f) in the evidence document.[2]
  7. (g)The main program needs to ask the user to input their requirements for a picture. The user will enter the colour of the frame, the maximum width, and the maximum height of the picture. The program will then search the array of pictures, and output the picture description, the width, and the height of any picture that meets the user's requirements. The program should allow the user to input the colour in any case (e.g. Silver, silver, or SILVER), and still output the correct results. Edit the main program to perform the described actions. Save your program. Copy and paste the program code into part 2(g) in the evidence document.[7]
  8. (h)Test your program by inputting the following search criteria: : BLACK, 100, 100 silver, 25, 25 Take screenshots to show the output for both search criteria. Copy and paste the screenshots into part 2(h) in the evidence document.[2]

Mark scheme

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

  1. [1] class declared (with appropriate close) with identifier Picture
  2. [1] correct attribute declarations with Data types (Description, Frame colour = string, Width, Height = integer.)
  3. [1] ...as private
  4. [1] correct constructor (with appropriate close) with four parameters...
  5. [1] ...parameters assigned to attributes
  6. [1] 1 Get method taking no parameter...
  7. [1] ...returning correct attribute
  8. [1] remaining 3 correct methods
  9. [1] Set method (procedure) taking parameter (no return)
  10. [1] ...assigning parameter to correct attribute
  11. [1] 1 mark for declaring array of type Picture with 100 elements
  12. [1] Function/procedure declared with correct name (and close, passing array by reference or global array declared)
  13. [1] opening Pictures.txt for Read
  14. [1] looping until EOF / or equivalent
  15. [1] ...reading each set of 4 lines from the file within loop
  16. [1] creating object of type Picture ...with Description, Width, Height, Frame colour from File as parameters
  17. [1] ..adding to next array element/appending
  18. [1] closing the File (in an appropriate place)
  19. [1] counts and returns number of pictures in array
  20. [1] Exception with opening the file inside... ...appropriate catch and output
  21. [1] calling function ReadData()
  22. [1] ...store/use the Number of elements returned/by reference based on answer to part 2e
  23. [1] taking as input all three values (colour, width, height)
  24. [1] converting colour to lowercase // uppercase
  25. [1] looping through array ...using returned value from part 2(f) as max index
  26. [1] .within loop, checking if Array[index].FrameColour matches input
  27. [1] .and checking if Array[index].FrameWidth <= input Width
  28. [1] ...and checking if Array[index].FrameHeight <= input Height
  29. [1] ...all using Get methods
  30. [1] outputting the Picture Description, Width and Height for all/any matching Pictures
  31. [1] 1 mark for screenshot showing output for BLACK, 100, 100
  32. [1] 1 mark for showing no outputs for silver, 25, 25

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, 30 marks.
Source
A-Level Computer Science, Oct/Nov 2021 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