Question 13
AQA Computer Science June 2024 Paper 1 (7517/1)A level14 marks
On the specification
- 13.1
- 3.1 Fundamentals of programming3.2 Fundamentals of data structures3.3 Systematic approach to problem solving
- 13.2
- 3.3 Systematic approach to problem solving
- 13.3
- 4.2 Fundamentals of data structures
- 13.4
- 4.2 Fundamentals of data structures
Question text
13 This question extends the Skeleton Program by giving the user an option to shift all the cells in one row in the puzzle one place to the left. When shifting left, the first cell in the row will move to the last position in the row. Figure 8 shows an example puzzle and Figure 9 shows the result obtained from shifting all the cells in row 2 from the puzzle in Figure 8 one place to the left. Figure 8 12 3 4 5 6 7 8 8 @ 7 @ @ 6 5 @ 4 3 @ @ 2 X X X 1 @ Figure 9 12 3 4 5 6 7 8 8 @ 7 @ @ 6 5 @ 4 3 @ @ 2 X X X 1 @ After the cells have been shifted, the user’s score should be reduced by 20 and the new state of the grid and the user’s new score should be displayed. No other changes to the user’s score should be made. Shifting the cells does not count as a turn. After choosing to shift cells, the user should carry on with the rest of their turn by selecting a cell to place a symbol in. When answering this question, you should make sure your program code will work for any size of puzzle grid. What you need to do Task 1 Create a new method called ShiftCellsInRowLeft in the Puzzle class that takes an integer parameter that specifies the row number to use with the shift. Each cell, in the row indicated by the parameter, should be moved in Grid so that it is one place to the left; the leftmost cell should shift to the end of the row. Task 2 Modify the AttemptPuzzle method in the Puzzle class so that it gives the user the option to shift the cells in a row. Inside the iteration structure used to get a row number from the user your program should: • display a modified message telling the user to enter a row number or to enter 0 to shift cells • if the user enters 0: o ask the user to enter the row number for the row to shift o call the method ShiftCellsInRowLeft with the number entered as a parameter o subtract 20 from the user’s score o display the new grid o display the new score o set Valid to be false. Task 3 Test that the changes you have made work: • run the Skeleton Program • load the file puzzle2 • enter 0 • enter 1 • enter 1 Evidence that you need to provide Include the following evidence in your Electronic Answer Document. 13.1 Your PROGRAM SOURCE CODE for the new method ShiftCellsInRowLeft and the amended method AttemptPuzzle. [11 marks] 13.2 SCREEN CAPTURE(S) showing the requested test. [1 mark] 13.3 The movement of the cells within a row can be described using vectors. State the 2-vector that describes the movement for all but the leftmost cell in the row. [1 mark] 13.4 State the 2-vector that describes the movement for the leftmost cell in the row. Your vector should work for any grid size. [1 mark]