9618/43 · October/November 2023 · Worked solutions

Step-by-step solutions based on the mark scheme (not a mark-scheme dump).

Question 1

Paper page 2 for Q1
Original paper page 2

Part 1(a)(i) — solution

  1. Function header (and end where appropriate) taking one string parameter
  2. Calculating length of parameter string
  3. Looping correct number of times
  4. Checking the first character against all vowels
  5. Accessing the remainder of the string
  6. Remainder of function correct with nothing extra i.e. totalling, must match structure of given algorithm

Visual Basic (VB.NET)

Function IterativeVowels(Value)
    Dim Total As Integer = 0
    Dim FirstCharacter As Char
    For x = 0 To Len(Value) - 1
       FirstCharacter = Left(Value, 1)
       If FirstCharacter = "a" Or FirstCharacter = "e" Or FirstCharacter = "i" Or FirstCharacter = "o" Or
 FirstCharacter = "u" Then
           Total = Total + 1
       End If
       Value = Right(Value, Len(Value) - 1)
    Next
    Return Total
 End Function

 2023                                          Page 5 of 37

9618/43                                       Cambridge International AS & A Level – Mark Scheme                       October/November 2023

Python

def IterativeVowels(Value):
    Total = 0
    for X in range(0, len(Value)):
       FirstCharacter = Value[0]
       if FirstCharacter == 'a' or FirstCharacter == 'e' or FirstCharacter == 'i' or FirstCharacter == 'o'
 or FirstCharacter == 'u':
           Total = Total + 1

         Value = Value[1:len(Value)]
      return Total

Mark points

  • Function header (and end where appropriate) taking one string parameter
  • Calculating length of parameter string
  • Looping correct number of times
  • Checking the first character against all vowels
  • Accessing the remainder of the string
  • Remainder of function correct with nothing extra i.e. totalling, must match structure of given algorithm

Part 1(a)(ii) — solution

  1. Calling the function with "house"
  2. Outputting the return value

Visual Basic (VB.NET)

Console.WriteLine(IterativeVowels("house"))

Python

print(IterativeVowels("house"))

Mark points

  • Calling the function with "house"
  • Outputting the return value

Part 1(a)(iii) — solution

One mark for screenshot outputting 3 1

Mark points

  • Include the ideas shown in the solution above.

Part 1(b)(i) — solution

  1. Recursive call
  2. Function header (and end where appropriate) taking string parameter (returning integer where given)
  3. Base case checking (length is 0) and returning 0
  4. Extracting first character and checking if a vowel …
  5. … if it is a vowel, returning 1 + recursive call with 1 less character
  6. … if not a vowel, return recursive call with 1 less character

Visual Basic (VB.NET)

Function RecursiveVowels(Value)
    Dim firstCharacter As Char
    If Len(Value) = 0 Then
       Return 0
    Else
       firstCharacter = Left(Value, 1)
       If firstCharacter = "a" Or firstCharacter = "e" Or firstCharacter = "i" Or firstCharacter = "o" Or
 firstCharacter = "u" Then
           Return 1 + RecursiveVowels(Right(Value, Len(Value) - 1))
       Else
           Return RecursiveVowels(Right(Value, Len(Value) - 1))

 2023                                          Page 7 of 37

9618/43                                       Cambridge International AS & A Level – Mark Scheme    October/November 2023

       End If
    End If
 End Function

Python

def RecursiveVowels(Value):
    if len(Value) == 0:
       return 0
    else:
       FirstCharacter = Value[0]
    if FirstCharacter == 'a' or FirstCharacter == 'e' or FirstCharacter == 'i' or FirstCharacter == 'o' or
 FirstCharacter == 'u':
       return 1 + RecursiveVowels(Value[1:len(Value)])
    else:
       return RecursiveVowels(Value[1:len(Value)])

Mark points

  • Recursive call
  • Function header (and end where appropriate) taking string parameter (returning integer where given)
  • Base case checking (length is 0) and returning 0
  • Extracting first character and checking if a vowel …
  • … if it is a vowel, returning 1 + recursive call with 1 less character
  • … if not a vowel, return recursive call with 1 less character

Part 1(b)(ii) — solution

One mark for calling recursive function with "imagine" and outputting return value 1 Example program code: VB.NET Console.WriteLine(RecursiveVowels("imagine")) Python print(RecursiveVowels("imagine"))

Visual Basic (VB.NET)

Console.WriteLine(RecursiveVowels("imagine"))

Python

print(RecursiveVowels("imagine"))

Mark points

  • Include the ideas shown in the solution above.

Part 1(b)(iii) — solution

One mark for screenshot showing 4 1 2023 Page 8 of 37 9618/43 Cambridge International AS & A Level – Mark Scheme October/November 2023

Mark points

  • Include the ideas shown in the solution above.

Question 2

Paper page 4 for Q2
Original paper page 4

Part 2(a)(i) — solution

  1. (Global) array with identifier Queue with (minimum) 50 elements (of type string)
  2. TailPointer (integer) initialised to 0, HeadPointer (integer) initialised to -1

Visual Basic (VB.NET)

Dim Queue(50) As String
               Dim HeadPointer As Integer
               Dim TailPointer As Integer
               Sub Main(args As String())
                  HeadPointer = -1
                  TailPointer = 0
               End Sub

Python

global Queue #string 50 elements
               global HeadPointer
               global TailPointer
               #main
               Queue = []
               HeadPointer = -1
               TailPointer = 0

 2023                                                         Page 9 of 37

9618/43                                      Cambridge International AS & A Level – Mark Scheme         October/November 2023

Mark points

  • (Global) array with identifier Queue with (minimum) 50 elements (of type string)
  • TailPointer (integer) initialised to 0, HeadPointer (integer) initialised to -1

Part 2(a)(ii) — solution

  1. Procedure Enqueue() header (and close where appropriate) with one (string) parameter
  2. Checking if queue is full and outputting suitable message
  3. … otherwise inserting parameter to next space
  4. … increment TailPointer and set HeadPointer to 0 if first item (HeadPointer = -1)

Visual Basic (VB.NET)

Sub Enqueue(Data)
                  If TailPointer = 50 Then
                     Console.WriteLine("Queue full")
                  Else
                     Queue(TailPointer) = Data
                     TailPointer = TailPointer + 1
                     If (HeadPointer = -1) Then
                         HeadPointer = 0
                     End If
                  End If
               End Sub

 2023                                                     Page 10 of 37

9618/43                               Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • Procedure Enqueue() header (and close where appropriate) with one (string) parameter
  • Checking if queue is full and outputting suitable message
  • … otherwise inserting parameter to next space
  • … increment TailPointer and set HeadPointer to 0 if first item (HeadPointer = -1)

Part 2(a)(ii) — solution

  1. if TailPointer == 50:
  2. TailPointer +=1
  3. if HeadPointer == -1:
  4. HeadPointer = 0

Python

def Enqueue(Data):
                  global TailPointer
                  global HeadPointer
                  global Queue
                  if TailPointer == 50:
                     print("Queue full")
                  else:
                     Queue.append(Data)
                     TailPointer +=1
                     if HeadPointer == -1:
                         HeadPointer = 0

 2023                                              Page 11 of 37

9618/43                                     Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • if TailPointer == 50:
  • TailPointer +=1
  • if HeadPointer == -1:
  • HeadPointer = 0

Part 2(a)(iii) — solution

  1. Function header Dequeue() (and end where appropriate) with no parameter
  2. Checking if empty …
  3. … outputting suitable message and returning "Empty"
  4. (otherwise) incrementing head pointer
  5. returning next value (at head pointer before incrementing)

Visual Basic (VB.NET)

Function Dequeue()
                  If HeadPointer = -1 Or HeadPointer = TailPointer Then
                     Console.WriteLine("Queue empty")
                     Return "Empty"
                  Else
                     HeadPointer = HeadPointer + 1
                     Return Queue(HeadPointer - 1)
                  End If
               End Function

 2023                                                    Page 12 of 37

9618/43                                Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • Function header Dequeue() (and end where appropriate) with no parameter
  • Checking if empty …
  • … outputting suitable message and returning "Empty"
  • (otherwise) incrementing head pointer
  • returning next value (at head pointer before incrementing)

Part 2(a)(iii) — solution

  1. if HeadPointer == -1 or HeadPointer == TailPointer:
  2. HeadPointer +=1

Python

def Dequeue():
                  global Queue
                  global HeadPointer
                  if HeadPointer == -1 or HeadPointer == TailPointer:
                     print("Queue empty")
                     return "Empty"
                  else:
                     HeadPointer +=1
                     return Queue[HeadPointer - 1]

 2023                                               Page 13 of 37

9618/43                                        Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • if HeadPointer == -1 or HeadPointer == TailPointer:
  • HeadPointer +=1

Part 2(b) — solution

  1. Procedure header ReadData() with no parameters
  2. Opening file …
  3. … and closing file
  4. Looping until EOF/set amount
  5. Reading in each value
  6. … calling Enqueue() with each value
  7. Use of exception handling with appropriate output

Visual Basic (VB.NET)

Sub ReadData()
                  Try
                      Dim DataReader As New System.IO.StreamReader("QueueData.txt")
                      Do Until DataReader.EndOfStream
                         Enqueue(DataReader.ReadLine())

 2023                                                           Page 14 of 37

9618/43                                Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • Procedure header ReadData() with no parameters
  • Opening file …
  • … and closing file
  • Looping until EOF/set amount
  • Reading in each value
  • … calling Enqueue() with each value
  • Use of exception handling with appropriate output

Part 2(b) — solution

  1. DataFile = open("QueueData.txt")

Python

def ReadData():
                   try:
                      DataFile = open("QueueData.txt")
                      for Line in DataFile:
                         Enqueue(Line.strip())
                      DataFile.close()
                   except IOError:
                      print("No file")

 2023                                               Page 15 of 37

9618/43                                     Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • DataFile = open("QueueData.txt")

Part 2(c)(i) — solution

  1. Declaration of record type/class RecordData
  2. ID as a string and total as an Integer

Visual Basic (VB.NET)

Structure RecordData
                     Dim ID As String
                     Dim Total As Integer
                  End Structure

Python

class RecordData:

                  #self. ID string
                  #self. Total integer
                  def init (self, IDP, TotalP):
                     self. ID = IDP
                     self. Total = TotalP

 2023                                                    Page 16 of 37

9618/43                                      Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • Declaration of record type/class RecordData
  • ID as a string and total as an Integer

Part 2(c)(i) — solution

  1. self. ID = Value
  2. self. Total = Value

Mark points

  • self. ID = Value
  • self. Total = Value

Part 2(c)(ii) — solution

  1. (global) 1D Array named Records of type RecordData
  2. (global) NumberRecords declared as integer and initialised to 0

Visual Basic (VB.NET)

Dim Records(49) As RecordData Dim NumberRecords As Integer
               Sub Main(args As String())
                  NumberRecords = 0
               End Sub

Python

#main
               Records = [] #50 elements of type RecordData NumberRecords = 0

 2023                                                      Page 17 of 37

9618/43                                         Cambridge International AS & A Level – Mark Scheme        October/November 2023

Mark points

  • (global) 1D Array named Records of type RecordData
  • (global) NumberRecords declared as integer and initialised to 0

Part 2(c)(iii) — solution

  1. Incrementing NumberRecords each time (twice) a new record is added
  2. Procedure header (and end) and using Dequeue() and storing/using return value
  3. Checking if NumberRecords is 0 and creating a new record with ID and total as 1:
  4. Looping through all array elements to find matching ID and incrementing total if found
  5. Adding new record if record is not found, storing ID and total as 1

Python

loop end
                       IF Records[X].ID = DataAccessed THEN
                           Records[X].Total  Records[X].Total + 1
                           Flag  TRUE
                       ENDIF
                   NEXT X
               •   Adding new record if record is not found, storing ID and total as 1
                   IF Flag = FALSE THEN
                       Records[NumberRecords].ID  DataAccessed
                       Records[NumberRecords].Total  1
                       NumberRecords  NumberRecords + 1
                   ENDIF

 2023                                                          Page 18 of 37

9618/43                                    Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • Incrementing NumberRecords each time (twice) a new record is added
  • Procedure header (and end) and using Dequeue() and storing/using return value
  • Checking if NumberRecords is 0 and creating a new record with ID and total as 1:
  • Looping through all array elements to find matching ID and incrementing total if found
  • Adding new record if record is not found, storing ID and total as 1

Part 2(c)(iii) — solution

  1. Example program code:

Visual Basic (VB.NET)

Sub TotalData()
                  Dim DataAccessed As String
                  Dim Flag As Boolean = False
                  DataAccessed = Dequeue()

 2023                                                   Page 19 of 37

9618/43                                Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • Example program code:

Part 2(c)(iii) — solution

  1. If NumberRecords = 0 Then
  2. Records(NumberRecords).ID = DataAccessed
  3. Records(NumberRecords).Total = Records(NumberRecords).Total + 1
  4. NumberRecords = NumberRecords + 1
  5. Flag = True
  6. For X = 0 To NumberRecords – 1
  7. If Records(X).ID = DataAccessed Then
  8. Records(X).Total = Records(X).Total + 1
  9. Flag = True
  10. If Flag = False Then
  11. Records(NumberRecords).ID = DataAccessed
  12. Records(NumberRecords).Total = Records(NumberRecords).Total + 1
  13. NumberRecords = NumberRecords + 1
  14. Flag = False
  15. DataAccessed = Dequeue()
  16. if NumberRecords == 0:

Python

def TotalData():
                  global NumberRecords
                  global Records
                  Flag = False
                  DataAccessed = Dequeue()

                  if NumberRecords == 0:
                     Records.append(RecordData(DataAccessed, 1))

 2023                                               Page 20 of 37

9618/43                                        Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • If NumberRecords = 0 Then
  • Records(NumberRecords).ID = DataAccessed
  • Records(NumberRecords).Total = Records(NumberRecords).Total + 1
  • NumberRecords = NumberRecords + 1
  • Flag = True
  • For X = 0 To NumberRecords – 1
  • If Records(X).ID = DataAccessed Then
  • Records(X).Total = Records(X).Total + 1
  • Flag = True
  • If Flag = False Then
  • Records(NumberRecords).ID = DataAccessed
  • Records(NumberRecords).Total = Records(NumberRecords).Total + 1
  • NumberRecords = NumberRecords + 1
  • Flag = False
  • DataAccessed = Dequeue()
  • if NumberRecords == 0:

Part 2(c)(iii) — solution

  1. NumberRecords += 1
  2. Flag = True
  3. if(Records[X].GetID() == DataAccessed):
  4. Flag = True
  5. if Flag == False:
  6. NumberRecords += 1

Mark points

  • NumberRecords += 1
  • Flag = True
  • if(Records[X].GetID() == DataAccessed):
  • Flag = True
  • if Flag == False:
  • NumberRecords += 1

Part 2(d) — solution

  1. Looping through all array elements and outputting ID and total in correct format

Visual Basic (VB.NET)

Sub OutputRecords()
    For X = 0 To NumberRecords - 1
       Console.WriteLine("ID " & Records(X).ID & " Total " & Records(X).Total)
    Next
 End Sub

Python

def OutputRecords():
    for X in range(0, NumberRecords):
       print("ID", Records[X].GetID(), " Total ", Records[X].GetTotal())

 2023                                          Page 22 of 37

9618/43                                     Cambridge International AS & A Level – Mark Scheme       October/November 2023

Mark points

  • Looping through all array elements and outputting ID and total in correct format

Part 2(e)(i) — solution

  1. Calling ReadData() first and OutputRecords() last
  2. Looping through all queue elements and calling TotalData() for each queue element

Visual Basic (VB.NET)

Sub Main(args As String())
                  HeadPointer = 0
                  TailPointer = 0
                  ReadData()
                  NumberRecords = 0
                  While HeadPointer <> TailPointer
                     TotalData()
                  End While
                  OutputRecords()
               End Sub

 2023                                                    Page 23 of 37

9618/43                                       Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • Calling ReadData() first and OutputRecords() last
  • Looping through all queue elements and calling TotalData() for each queue element

Part 2(e)(i) — solution

  1. #main Queue = []
  2. Records = []
  3. HeadPointer = 0
  4. TailPointer = 0
  5. NumberRecords = 0
  6. while HeadPointer != TailPointer:

Python

#main Queue = []
               Records = []
               HeadPointer = 0
               TailPointer = 0
               ReadData()
               NumberRecords = 0

               while HeadPointer != TailPointer:
                  TotalData()
                     OutputRecords()

Mark points

  • #main Queue = []
  • Records = []
  • HeadPointer = 0
  • TailPointer = 0
  • NumberRecords = 0
  • while HeadPointer != TailPointer:

Part 2(e)(ii) — solution

One mark for screenshot e.g. 1 2023 Page 24 of 37 9618/43 Cambridge International AS & A Level – Mark Scheme October/November 2023

Mark points

  • Include the ideas shown in the solution above.

Question 3

Paper page 8 for Q3
Original paper page 8

Part 3(a)(i) — solution

  1. Class header (and end where appropriate)
  2. Three attributes with correct names and data types
  3. Constructor header (and end where appropriate) with 3 parameters
  4. Within constructor, assigns attributes to parameters

Visual Basic (VB.NET)

Class Character
                  Private XPosition As Integer
                  Private YPosition As Integer
                  Private Name As String

                  Sub New(XPositionP, YPositionP, NameP)
                     XPosition = XPositionP
                     YPosition = YPositionP
                     Name = NameP
                  End Sub
               End Class

 2023                                                     Page 25 of 37

9618/43                                  Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • Class header (and end where appropriate)
  • Three attributes with correct names and data types
  • Constructor header (and end where appropriate) with 3 parameters
  • Within constructor, assigns attributes to parameters

Part 3(a)(i) — solution

  1. self.XPosition = XPositionP
  2. self.YPosition = YPositionP
  3. self.Name = NameP

Python

class Character:
                  #self.XPosition integer
                  #self.YPosition integer
                  #self.Name string

                  def     init (self, XPositionP, YPositionP, NameP):
                        self.XPosition = XPositionP
                        self.YPosition = YPositionP
                        self.Name = NameP

 2023                                                 Page 26 of 37

9618/43                                     Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • self.XPosition = XPositionP
  • self.YPosition = YPositionP
  • self.Name = NameP

Part 3(a)(ii) — solution

  1. 1 get header with no parameter …
  2. … returning correct value
  3. 2nd get method

Visual Basic (VB.NET)

Function GetXPosition()
                  Return XPosition
               End Function
               Function GetYPosition()
                  Return YPosition
               End Function

Python

def GetXPosition(self):
                  return self. XPosition

               def GetYPosition(self):
                  return self. YPosition

 2023                                                    Page 27 of 37

9618/43                                          Cambridge International AS & A Level – Mark Scheme             October/November 2023

Mark points

  • 1 get header with no parameter …
  • … returning correct value
  • 2nd get method

Part 3(a)(iii) — solution

  1. 1 set method header (and end where appropriate) with parameter …
  2. … adding parameter to X/Y Position attribute and storing in the X/Y attribute
  3. If (resulting value is) more than 10 000 limiting to 10 000 and if less than 0 limiting to 0
  4. Second correct set method

Visual Basic (VB.NET)

Function SetXPosition(Value)
                  XPosition = XPosition + Value
                  If XPosition > 10000 Then
                     XPosition = 10000

 2023                                                            Page 28 of 37

9618/43                                Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • 1 set method header (and end where appropriate) with parameter …
  • … adding parameter to X/Y Position attribute and storing in the X/Y attribute
  • If (resulting value is) more than 10 000 limiting to 10 000 and if less than 0 limiting to 0
  • Second correct set method

Part 3(a)(iii) — solution

  1. XPosition = 0
  2. YPosition = YPosition + Value
  3. YPosition = 10000
  4. YPosition = 0
  5. self. XPosition = self. XPosition + Value
  6. self.XPosition = 10000
  7. self.XPosition = 0
  8. self.YPosition = self.YPosition + Value
  9. self.YPosition = 10000
  10. self.YPosition = 0

Python

def SetXPosition(self, Value):
                  self. XPosition = self. XPosition + Value
                  if(self.XPosition > 10000):
                     self.XPosition = 10000
                  elif self.XPosition < 0:
                     self.XPosition = 0

               def SetYPosition(self, Value):
                  self.YPosition = self.YPosition + Value
                  if(self.YPosition > 10000):
                     self.YPosition = 10000
                  elif self.YPosition < 0:
                     self.YPosition = 0

 2023                                               Page 29 of 37

9618/43                                  Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • XPosition = 0
  • YPosition = YPosition + Value
  • YPosition = 10000
  • YPosition = 0
  • self. XPosition = self. XPosition + Value
  • self.XPosition = 10000
  • self.XPosition = 0
  • self.YPosition = self.YPosition + Value
  • self.YPosition = 10000
  • self.YPosition = 0

Part 3(a)(iv) — solution

  1. Method header with (string) parameter
  2. Checking parameter for direction …
  3. … using SetYPosition() and SetXPosition() correctly …
  4. … with correct parameters

Visual Basic (VB.NET)

Overridable Sub Move(Direction)
                  If Direction = "up" Then
                     SetYPosition(10)
                  ElseIf Direction = "down" Then
                     SetYPosition(-10)
                  ElseIf Direction = "right" Then
                     SetXPosition(10)
                  ElseIf Direction = "left" Then
                     SetXPosition(-10)
                  End If
               End Sub

 2023                                                 Page 30 of 37

9618/43                                     Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • Method header with (string) parameter
  • Checking parameter for direction …
  • … using SetYPosition() and SetXPosition() correctly …
  • … with correct parameters

Part 3(a)(iv) — solution

  1. if(Direction == "up"):
  2. elif(Direction == "down"):
  3. elif(Direction == "right"):

Python

def Move(self, Direction):
                  if(Direction == "up"):
                     self.SetYPosition(10)
                  elif(Direction == "down"):
                     self.SetYPosition(-10)
                  elif(Direction == "right"):
                     self.SetXPosition(10)
                  else:
                     self.SetXPosition(-10)

Mark points

  • if(Direction == "up"):
  • elif(Direction == "down"):
  • elif(Direction == "right"):

Part 3(b) — solution

  1. New instance of Character created with identifier Jack …
  2. … correct constructor called and values passed

Visual Basic (VB.NET)

Dim Jack As Character = New Character(50, 50, "Jack")

Python

Jack = Character(50, 50, "Jack")

 2023                                                    Page 31 of 37

9618/43                                       Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • New instance of Character created with identifier Jack …
  • … correct constructor called and values passed

Part 3(c)(i) — solution

  1. Class header inheriting from Character
  2. Constructor taking all 3 parameters …
  3. … calling parent/super constructor with the 3 parameters

Visual Basic (VB.NET)

Class BikeCharacter
                  Inherits Character

                  Sub New(XPositionP, YPositionP, NameP)
                     MyBase.New(XPositionP, YPositionP, NameP)
                  End Sub
               End Class

Python

class BikeCharacter(Character):
                  def init (self, XPositionP, YPositionP, NameP):
                     super(). init (XPositionP, YPositionP, NameP)

 2023                                                       Page 32 of 37

9618/43                                     Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • Class header inheriting from Character
  • Constructor taking all 3 parameters …
  • … calling parent/super constructor with the 3 parameters

Part 3(c)(ii) — solution

  1. Method header taking parameter and overriding parent/super Move()
  2. Correct changes to method to update values by 20

Visual Basic (VB.NET)

Overrides Sub
                  Move(Direction) If
                  Direction = "up" Then
                     SetYPosition(20)
                  ElseIf Direction = "down" Then
                     SetYPosition(-20)
                  ElseIf Direction = "right" Then
                     SetXPosition(20)
                  ElseIf Direction = "left" Then
                     SetXPosition(-20)

                  End If
               End Sub

 2023                                                    Page 33 of 37

9618/43                                     Cambridge International AS & A Level – Mark Scheme   October/November 2023

Mark points

  • Method header taking parameter and overriding parent/super Move()
  • Correct changes to method to update values by 20

Part 3(c)(ii) — solution

  1. if(Direction == "up"):
  2. elif(Direction == "down"):
  3. elif(Direction == "right"):

Python

def Move(self, Direction):
                  if(Direction == "up"):
                     super().SetYPosition(20)
                  elif(Direction == "down"):
                     super().SetYPosition(-20)
                  elif(Direction == "right"):
                     super().SetXPosition(2)
                  else:
                     super().SetXPosition(-20)

Mark points

  • if(Direction == "up"):
  • elif(Direction == "down"):
  • elif(Direction == "right"):

Part 3(d) — solution

  1. Declaring new BikeCharacter with correct values e.g

Visual Basic (VB.NET)

Dim Karla As BikeCharacter = New BikeCharacter(100, 50, "Karla")

Python

Karla = BikeCharacter(100, 50, "Karla")

 2023                                                    Page 34 of 37

9618/43                                         Cambridge International AS & A Level – Mark Scheme                       October/November 2023

Mark points

  • Declaring new BikeCharacter with correct values e.g

Part 3(e)(i) — solution

  1. Reading in both values (character and direction) with appropriate prompts
  2. Character name is validated as e.g. Jack/Karla, and direction is validated as e.g. up/down/left/right
  3. Calling Move() for the character input, with direction input as a parameter
  4. Outputting character's new X and Y position in a suitable format …
  5. … using get methods

Mark points

  • Reading in both values (character and direction) with appropriate prompts
  • Character name is validated as e.g. Jack/Karla, and direction is validated as e.g. up/down/left/right
  • Calling Move() for the character input, with direction input as a parameter
  • Outputting character's new X and Y position in a suitable format …
  • … using get methods

Part 3(e)(i) — solution

  1. CharacterToMove = Console.ReadLine.ToLower()
  2. CharacterToMove = Console.ReadLine
  3. Direction = Console.ReadLine.ToLower()
  4. Direction = Console.ReadLine
  5. If CharacterToMove = "jack"
  6. Console.WriteLine("Jack's new position is X = " & Jack.GetXPosition & " Y = " &
  7. Console.WriteLine("Karla's new position is X = " & Karla.GetXPosition & " Y = " &

Visual Basic (VB.NET)

Console.WriteLine("Would you like to move Jack or Karla?")
               CharacterToMove = Console.ReadLine.ToLower()
               While CharacterToMove <> "jack" And CharacterToMove <> "karla"
                  Console.WriteLine("Invalid try again")
                  CharacterToMove = Console.ReadLine
               End While
               Console.WriteLine("Which direction? Up, down, left or right")
               Direction = Console.ReadLine.ToLower()
               While Direction <> "up" And Direction <> "down" And Direction <> "left" And Direction <>
               "right"
                  Console.WriteLine("Invalid try again")
                  Direction = Console.ReadLine
               End While
               If CharacterToMove = "jack"
                  Then Jack.Move(Direction)
                  Console.WriteLine("Jack's new position is X = " & Jack.GetXPosition & " Y = " &
               Jack.GetYPosition)
               Else
                  Karla.Move(Direction)
                  Console.WriteLine("Karla's new position is X = " & Karla.GetXPosition & " Y = " &
               Karla.GetYPosition)
               End If
               Console.WriteLine("Would you like to Continue? Enter True to continue, or anything else to
               quit")

 2023                                               Page 36 of 37

9618/43                                 Cambridge International AS & A Level – Mark Scheme     October/November 2023

Mark points

  • CharacterToMove = Console.ReadLine.ToLower()
  • CharacterToMove = Console.ReadLine
  • Direction = Console.ReadLine.ToLower()
  • Direction = Console.ReadLine
  • If CharacterToMove = "jack"
  • Console.WriteLine("Jack's new position is X = " & Jack.GetXPosition & " Y = " &
  • Console.WriteLine("Karla's new position is X = " & Karla.GetXPosition & " Y = " &

Part 3(e)(i) — solution

  1. CharacterToMove = input("Would you like to move Jack or Karla?").lower()
  2. while CharacterToMove != "jack" and CharacterToMove != "karla":
  3. CharacterToMove = input("Invalid try again")
  4. Direction = input("Which direction? Up, down, left or right?")
  5. while Direction != "up" and Direction != "down" and Direction != "left" and Direction !=
  6. Direction = input("Invalid try again")
  7. if CharacterToMove == "jack":
  8. print("Jack's new position is X =", Jack.GetXPosition(), "Y =", Jack.GetYPosition())
  9. print("Karla's new position is X =", Karla.GetXPosition(), "Y =", Karla.GetYPosition())

Python

CharacterToMove = input("Would you like to move Jack or Karla?").lower()
               while CharacterToMove != "jack" and CharacterToMove != "karla":
                  CharacterToMove = input("Invalid try again")
               Direction = input("Which direction? Up, down, left or right?")
               while Direction != "up" and Direction != "down" and Direction != "left" and Direction !=
               "right":
                  Direction = input("Invalid try again")
                  if CharacterToMove == "jack":
                     Jack.Move(Direction)
                     print("Jack's new position is X =", Jack.GetXPosition(), "Y =", Jack.GetYPosition())
               else:
                  Karla.Move(Direction)
               print("Karla's new position is X =", Karla.GetXPosition(), "Y =", Karla.GetYPosition())

Mark points

  • CharacterToMove = input("Would you like to move Jack or Karla?").lower()
  • while CharacterToMove != "jack" and CharacterToMove != "karla":
  • CharacterToMove = input("Invalid try again")
  • Direction = input("Which direction? Up, down, left or right?")
  • while Direction != "up" and Direction != "down" and Direction != "left" and Direction !=
  • Direction = input("Invalid try again")
  • if CharacterToMove == "jack":
  • print("Jack's new position is X =", Jack.GetXPosition(), "Y =", Jack.GetYPosition())
  • print("Karla's new position is X =", Karla.GetXPosition(), "Y =", Karla.GetYPosition())

Part 3(e)(ii) — solution

One mark for each test 2 2023 Page 37 of 37

Mark points

  • Include the ideas shown in the solution above.