Cambridge A Level Computer Science 9618 — 2023 Oct/Nov Paper 4 · Variant 2
9618/42/O/N/23 · 3 questions · 75 marks · ≈84 min
The question paper and its mark scheme, free to read here and free to download. This is Cambridge’s own paper, exactly as it was sat.
Question paper16 pages
















Mark scheme34 pages
Answers below. Sit the paper first if you are practising.


































Questions as text
Q1 · A program stores lower-case letters in two stacks
1 A program stores lower-case letters in two stacks. One stack stores vowels (a, e, i, o, u) and one stack stores consonants (letters that are not vowels). Each stack is implemented as a 1D array. (a) (i) Write program code to declare two 1D global arrays: StackVowel and StackConsonant. Each array needs to store up to 100 letters. The index of the first element in each array is 0. If you are writing in Python, include declarations using comments. Save your program as Question1_N23. Copy and paste the program code into part 1(a)(i) in the evidence document. [2] (ii) The global variable VowelTop is a pointer that stores the index of the next free space in StackVowel. The global variable ConsonantTop is a pointer that stores the index of the next free space in StackConsonant. VowelTop and ConsonantTop are both initialised to 0. Write program code to declare and initialise the two variables. If you are writing in Python, include declarations using comments. Save your program. Copy and paste the program code into part 1(a)(ii) in the evidence document. [1] (b) (i) The procedure PushData() takes one letter as a parameter. If the parameter is a vowel, it is pushed onto StackVowel and the relevant pointer updated. If the stack is full, a suitable message is output. If the parameter is a consonant, it is pushed onto StackConsonant and the relevant pointer updated. If the stack is full, a suitable message is output. You do not need to validate that the parameter is a letter. Write program code for PushData(). Save your program. Copy and paste the program code into part 1(b)(i) in the evidence document. [6] (ii) The file StackData.txt stores 100 lower-case letters. The procedure ReadData() reads each letter from the file and uses PushData() to push each letter onto its appropriate stack. Use appropriate exception handling if the file does not exist. Write program code for ReadData(). Save your program. Copy and paste the program code into part 1(b)(ii) in the evidence document. [6] (c) The function PopVowel() removes and returns the data at the top of StackVowel and updates the relevant pointer(s). The function PopConsonant() removes and returns the data from the top of StackConsonant and updates the relevant pointer(s). If either stack is empty, the string "No data" must be returned. Write program code to declare PopVowel() and PopConsonant(). Save your program. Copy and paste the program code into part 1(c) in the evidence document. [5] (d) The program first needs to call ReadData() and then: 1. prompt the user to input their choice of vowel or consonant 2. take, as input, the user’s choice 3. depending on the user’s choice, call PopVowel() or PopConsonant() and store the return value. The three steps are repeated until 5 letters have been successfully returned and stored. If either stack is empty at any stage, an appropriate message must be output. Once 5 letters have been successfully returned and stored, they are output on one line, for example: abyti (i) Write program code for the main program. Save your program. Copy and paste the program code into part 1(d)(i) in the evidence document. [6] (ii) Test your program with the following inputs: vowel consonant consonant vowel vowel Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 1(d)(ii) in the evidence document. [1]
Mark scheme: Question Answer Marks 1(a)(i) One mark each 2 • Two arrays with correct identifiers of type string/character • Each has 100 elements Example program code: Java public static String[] StackVowel = new String[100]; public static String[] StackConsonant = new String[100]; VB.NET Dim StackVowel(0 To 99) As Char Dim StackConsonant(0 To 99) As Char Python StackVowel = [] #string 100 StackConsonant = [] #string 100 1(a)(ii) One mark for 1 • Declaring both variables as type integer global and initialised to 0 Example program code: Java public static Integer VowelTop = 0; public static Integer ConsonantTop = 0; VB.NET Dim VowelTop As Integer = 0 Dim ConsonantTop As Integer = 0 Python global VowelTop #integer global ConsonantTop #integer #main VowelTop = 0 ConsonantTop = 0 1(b)(i) One mark each 6 • Procedure PushData() heading (and end where appropriate) taking one parameter • Checking if parameter is a (lowercase) vowel … • … checking if StackVowel is full and outputting suitable message • … otherwise inserting parameter in next position • … incrementing VowelTop • Repeated for Consonant Example program code: Java public static void PushData(String Letter){ if(Letter.equals("a") || Letter.equals("e") || Letter.equals("i") || Letter.equals("o") || Letter.equals("u")){ if(VowelTop == 100){ System.out.println("Vowel stack full"); }else{ StackVowel[VowelTop] = Letter; VowelTop++; } }else{ if(ConsonantTop == 100){ System.out.println("Consonant stack full"); }else{ StackConsonant[ConsonantTop] = Letter; ConsonantTop++; } } } 1(b)(i) VB.NET Sub PushData(Letter As Char) If Letter = "a" Or Letter = "e" Or Letter = "i" Or Letter = "o" Or Letter = "u" Then If VowelTop = 100 Then Console.WriteLine("Vowel stack full") Else StackVowel(VowelTop) = Letter VowelTop += 1 End If Else If ConsonantTop = 100 Then Console.WriteLine("Consonant stack full") Else StackConsonant(ConsonantTop) = Letter ConsonantTop += 1 End If End If End Sub Python def PushData(Letter): global VowelTop global ConsonantTop if Letter == "a" or Letter == "e" or Letter == "i" or Letter == "o" or Letter == "u": if VowelTop == 100: print("Vowel stack full") else: StackVowel.append(Letter) VowelTop = VowelTop + 1 else: if ConsonantTop == 100: print("Consonant stack full") else: StackConsonant.append(Letter) ConsonantTop = ConsonantTop + 1 1(b)(ii) One mark each 6 • Procedure header ReadData() with no parameter • Opening StackData.txt to read and closing file • Looping until EOF // Looping 100 times • Read each item from the file • Calling PushData() with each value as parameter • Appropriate exception handling with suitable output Example program code: Java private static void ReadData(){ try{ Scanner Scanner1 = new Scanner(new File("StackData.txt")); while(Scanner1.hasNextLine()){ PushData(Scanner1.next()); } Scanner1.close(); }catch(FileNotFoundException ex){ System.out.println("No file found"); } } VB.NET Sub ReadData() Try Dim DataReader As New System.IO.StreamReader("StackData.txt") Do Until DataReader.EndOfStream PushData(DataReader.ReadLine()) Loop DataReader.Close() 1(b)(ii) Catch ex As Exception Console.WriteLine("File not found") End Try End Sub Python def ReadData(): try: DataFile = open("StackData.txt") for Line in DataFile: PushData(Line.strip()) DataFile.close() except: print("File not found") 1(c) One mark each 5 • One function header with no parameter • Checking if stack is empty and returning "No data" • …otherwise, decrementing correct pointer • Returning value at top of stack • 2nd function fully correct Example program code: Java public static String PopVowel(){ String DataToReturn = ""; if(VowelTop - 1 >= 0){ VowelTop --; DataToReturn = StackVowel[VowelTop]; return DataToReturn; }else{ return "No data"; } } public static String PopConsonant(){ String DataToReturn = ""; if(ConsonantTop - 1 >= 0){ ConsonantTop--; DataToReturn = StackConsonant[ConsonantTop]; return DataToReturn; }else{ return "No data"; } } 1(c) VB.NET Function PopVowel() If VowelTop - 1 >= 0 Then VowelTop -= 1 Dim DataToReturn As Char = StackVowel(VowelTop) Return DataToReturn Else Return "No data" End If End Function Function PopConsonant() If ConsonantTop - 1 >= 0 Then ConsonantTop -= 1 Dim DataToReturn As Char = StackConsonant(ConsonantTop) Return DataToReturn Else Return "No data" End If End Function Python def PopVowel(): global VowelTop global ConsonantTop if VowelTop - 1 >= 0: VowelTop = VowelTop - 1 DataToReturn = StackVowel[VowelTop] del StackVowel[-1] return DataToReturn else: return "No data" 1(c) def PopConsonant(): global VowelTop global ConsonantTop if ConsonantTop - 1 >= 0: ConsonantTop = ConsonantTop - 1 DataToReturn = StackConsonant[ConsonantTop] del StackConsonant[-1] return DataToReturn else: return "No data" 1(d)(i) One mark each to max 6 6 • Calling ReadData() • Looping until 5 letters successfully accessed • Prompt and read in input of choice … • … if vowel is input calling PopVowel() and if consonant calling PopConsonant() … • … storing return values • Outputting appropriate message if no vowels and if no consonants (stacks full) within loop • Outputting the five returned letters on one line Example program code: Java public static void main(String args[]){ VowelTop = 0; ConsonantTop = 0; ReadData(); String Letters = ""; Boolean Flag = false; String Choice = ""; String DataAccessed = ""; for(Integer X = 0; X < 5; X++){ Flag = false; while(Flag == false){ System.out.println("Vowel or Consonant"); Scanner scanner = new Scanner(System.in); Choice = (scanner.nextLine()).toLowerCase(); if(Choice.equals("vowel")){ DataAccessed = PopVowel(); if(DataAccessed.equals("No data") == false){ Letters = Letters + DataAccessed; Flag = true; }else{ System.out.println("No vowels left"); } 1(d)(i) }else if(Choice.equals("consonant")){ DataAccessed = PopConsonant(); if(DataAccessed.equals("No data") == false){ Letters = Letters + DataAccessed; Flag = true; }else{ System.out.println("No consonants left"); } } } } System.out.println(Letters); } VB.NET Sub Main(args As String()) VowelTop = 0 ConsonantTop = 0 ReadData() Dim Letters As String = "" Dim Flag As Boolean = False Dim Choice As String Dim DataAccessed As String For x = 0 To 4 Flag = False While Flag = False Console.WriteLine("Vowel or Consonant?") Choice = Console.ReadLine().ToLower() If Choice = "vowel" Then DataAccessed = PopVowel() If DataAccessed <> "No data" Then Letters = Letters & DataAccessed Flag = True Else Console.WriteLine("No vowels left") 1(d)(i) End If ElseIf Choice = "consonant" Then DataAccessed = PopConsonant() If DataAccessed <> "No data" Then Letters = Letters & DataAccessed Flag = True Else Console.WriteLine("No consonants left") End If End If End While Next Console.WriteLine(Letters) End Sub Python #main VowelTop = 0 ConsonantTop = 0 ReadData() Letters = "" Flag = False for x in range(0, 5): Flag = False while Flag == False: Choice = input("Vowel or Consonant").lower() if Choice == "vowel": DataAccessed = PopVowel() if DataAccessed != "No data": Letters = Letters + DataAccessed Flag = True else: print("No vowels left") 1(d)(i) elif Choice == "consonant": DataAccessed = PopConsonant() if DataAccessed != "No data": Letters = Letters + DataAccessed Flag = True else: print("No consonants left") print(Letters) 1(d)(ii) One mark showing input in order vowel, cons, cons, vowel, vowel. Output is then utxoe 1 e.g.
Q2 · An integer is said to be divisible by another integer if the result of the division is…
2 An integer is said to be divisible by another integer if the result of the division is also an integer. For example: 10 is divisible by 1, 2, 5 and 10: • 10 ÷ 1 = 10 • 10 ÷ 2 = 5 • 10 ÷ 5 = 2 • 10 ÷ 10 = 1 10 is not divisible by 4: • 10 ÷ 4 = 2.5 1, 2, 5 and 10 are said to be the divisors of 10. The iterative function IterativeCalculate() totals all the divisors of its integer parameter and returns this total. Example 1: if the parameter is 10, the total will be 18 (1 + 2 + 5 + 10) . Example 2: if the parameter is 4, the total will be 7 (1 + 2 + 4) . A pseudocode algorithm for IterativeCalculate() is shown. FUNCTION IterativeCalculate(Number : INTEGER) RETURNS INTEGER DECLARE Total : Integer DECLARE ToFind : Integer ToFind Number ← Total 0 ← WHILE Number <> 0 IF ToFind MODULUS Number = 0 THEN Total Total + Number ← ENDIF Number Number - 1 ← ENDWHILE RETURN Total ENDFUNCTION The operator MODULUS calculates the remainder when one number is divided by another. (a) (i) Write program code for IterativeCalculate(). Save your program as Question2_N23. Copy and paste the program code into part 2(a)(i) in the evidence document. [5] (ii) Write program code to call IterativeCalculate() with 10 as the parameter and output the return value. Save your program. Copy and paste the program code into part 2(a)(ii) in the evidence document. [2] (iii) Test your program. Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 2(a)(iii) in the evidence document. [1] (b) IterativeCalculate() has been rewritten as the recursive function RecursiveValue(). A pseudocode algorithm for RecursiveValue() is given. The function is incomplete. FUNCTION RecursiveValue(Number : INTEGER, ToFind : INTEGER) RETURNS INTEGER IF Number = .............. THEN RETURN 0 ELSE IF ToFind .............. Number = 0 THEN RETURN .............. + RecursiveValue(Number - 1, ToFind) ELSE .............. RecursiveValue(Number - 1, ..............) ENDIF ENDIF ENDFUNCTION (i) Write program code for RecursiveValue(). Save your program. Copy and paste the program code into part 2(b)(i) in the evidence document. [7] (ii) Write program code to call RecursiveValue() with 50 as the first parameter and 50 as the second parameter and output the return value. Save your program. Copy and paste the program code into part 2(b)(ii) in the evidence document. [1] (iii) Test your program. Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 2(b)(iii) in the evidence document. [1]
Mark scheme: 2(a)(i) One mark each 5 • Function header with parameter • Correct loop • Modulus calculation • Return of correct value at correct place • Remainder of function correct Example program code: Java public static Integer IterativeCalculate(Integer Number){ Integer ToFind = Number; Integer Total = 0; while(Number != 0){ if(ToFind % Number == 0){ Total += Number; } Number--; } return Total; } VB.NET Function IterativeCalculate(Number As Integer) Dim total As Integer = 0 Dim ToFind As Integer = Number While Number <> 0 If ToFind Mod Number = 0 Then total = total + Number End If Number = Number - 1 End While Return total End Function 2(a)(i) Python def IterativeCalculate(Number): Total = 0 ToFind = Number while Number != 0: if ToFind % Number == 0: Total = Total + Number Number = Number - 1 return Total 2(a)(ii) One mark each 2 • Calling IterativeCalculate(10) • Outputting return value Example program code: Java System.out.println(IterativeCalculate(10)); VB.NET Sub Main(args As String()) Console.WriteLine(IterativeCalculate(10)) End Sub Python print(IterativeCalculate(10)) 2(a)(iii) One mark for screenshot showing 18 1 2(b)(i) One mark for each gap (5) 7 One mark for recursive calls both accurate and in correct places One mark for remainder of function with nothing superfluous FUNCTION RecursiveValue(Number : Integer, ToFind : Integer) RETURNS INTEGER IF Number = 0 THEN RETURN 0 ELSE IF ToFind MODULUS Number = 0 THEN RETURN Number + RecursiveValue(Number - 1, ToFind) ELSE RETURN RecursiveValue(Number - 1, ToFind) ENDIF ENDIF ENDFUNCTION Example program code: Java public static Integer RecursiveValue(Integer Number, Integer ToFind){ if(Number == 0){ return 0; }else{ if(ToFind % Number == 0){ return Number + RecursiveValue(Number - 1, ToFind); }else{ return RecursiveValue(Number - 1, ToFind); } } } 2(b)(i) VB.NET Function RecursiveValue(Number As Integer, ToFind As Integer) If Number = 0 Then Return 0 Else If ToFind Mod Number = 0 Then Return Number + RecursiveValue(Number - 1, ToFind) Else Return RecursiveValue(Number - 1, ToFind) End If End If End Function Python def RecursiveValue(Number, ToFind): if Number == 0: return 0 else: if ToFind % Number == 0: return Number + RecursiveValue(Number - 1, ToFind) else: return RecursiveValue(Number - 1, ToFind) 2(b)(ii) One mark for calling RecursiveValue(50,50)and outputting return value 1 Example program code: Java System.out.println(RecursiveValue(50,50)); VB.NET Console.WriteLine(RecursiveValue(50,50)) Python print(RecursiveValue(50,50)) 2(b)(iii) One mark for screenshot showing 93 1
Q3 · A computer game is written using object-oriented programming
3 A computer game is written using object-oriented programming. The game has multiple characters. The class Character stores data about the game characters. Each character has a name, date of birth, intelligence value and speed value. Character CharacterName : STRING stores the name of the character DateOfBirth : DATE stores the date of birth of the character Intelligence : REAL stores the intelligence value of the character Speed : INTEGER stores the speed value of the character Constructor() initialises CharacterName, DateOfBirth, Intelligence and Speed to the parameter values SetIntelligence() assigns the value of the parameter to Intelligence GetIntelligence() returns the value of Intelligence GetName() returns the name of the character ReturnAge() calculates and returns the age of the character as an integer Learn() increases the value of Intelligence by 10% (a) (i) Write program code to declare the class Character and its constructor. Do not declare the other methods. Use your programming language’s appropriate constructor. If you are writing in Python, include attribute declarations using comments. Save your program as Question3_N23. Copy and paste the program code into part 3(a)(i) in the evidence document. [5] (ii) The get methods GetIntelligence() and GetName() return the attribute values. Write program code for the methods GetIntelligence() and GetName(). Save your program. Copy and paste the program code into part 3(a)(ii) in the evidence document. [3] (iii) The method SetIntelligence() assigns the value of its parameter to the attribute. Write program code for SetIntelligence(). Save your program. Copy and paste the program code into part 3(a)(iii) in the evidence document. [2] (iv) The method Learn() increases the current value of Intelligence by 10%. Write program code for Learn(). Save your program. Copy and paste the program code into part 3(a)(iv) in the evidence document. [1] (v) The method ReturnAge() calculates and returns the age of the character in years as an integer. Assume that the current year is 2023 and only use the year from the date of birth for the calculation. For example, the method returns 18 if the character was born on any date in 2005. Write program code for the method ReturnAge(). Save your program. Copy and paste the program code into part 3(a)(v) in the evidence document. [2] (b) (i) Write program code to create a new instance of Character with the identifier FirstCharacter. The name of the character is Royal, date of birth is 1 January 2019, intelligence is 70 and speed is 30. Save your program. Copy and paste the program code into part 3(b)(i) in the evidence document. [2] (ii) Write program code to call the method Learn() for the character created in part 3(b)(i). Output the name, age and intelligence of the character in an appropriate message. Save your program. Copy and paste the program code into part 3(b)(ii) in the evidence document. [3] (iii) Test your program. Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 3(b)(iii) in the evidence document. [1] (c) The class MagicCharacter inherits from the class Character. A magic character has an element, for example, water. This element changes how they learn. The magic character’s element is stored in the additional attribute Element. MagicCharacter Element : STRING stores the element for the character Constructor() takes Element, CharacterName, DateOfBirth, Intelligence and Speed as parameters calls its parent class constructor with the appropriate values initialises Element to its parameter value Learn() alters the intelligence of the character depending on the character’s element (i) Write program code to declare the class MagicCharacter and its constructor. Do not declare the other method. Use your programming language’s appropriate constructor. If you are writing in Python, include attribute declarations using comments. Save your program. Copy and paste the program code into part 3(c)(i) in the evidence document. [5] (ii) The method Learn() overrides the parent class method and increases the intelligence depending on the character’s element. • If the element is fire or water, intelligence increases by 20%. • If the element is earth, intelligence increases by 30%. • If the element is not fire, water or earth the intelligence increases by 10%. Write program code for Learn(). Save your program. Copy and paste the program code into part 3(c)(ii) in the evidence document. [3]
Mark scheme: 3(a)(i) One mark each: 5 • Class declaration • Four attributes with correct data types • Constructor header • … taking 4 parameters • Setting attributes to parameter values Example program code: Java class Character{ private String CharacterName; private Date DateOfBirth; private Double Intelligence; private Integer Speed; public Character(String CName, Date DBirth, Double Intell, Integer SpeedP){ CharacterName = CName; DateOfBirth = DBirth; Intelligence = Intell; Speed = SpeedP; } } VB.NET Class Character Private CharacterName As String Private DateOfBirth As Date Private Intelligence As Single Private Speed As Integer Sub New(CName, DBirth, Intell, SpeedP) CharacterName = CName DateOfBirth = DBirth 3(a)(i) Intelligence = Intell Speed = SpeedP End Sub End Class Python class Character: #self.__CharacterName string #self.__DateOfBirth date #self.__Intelligence real #self.__Speed integer def __init__(self, CName, DBirth, Intell, SpeedP): self.__CharacterName = CName self.__DateOfBirth = DBirth self.__Intelligence = Intell self.__Speed = SpeedP 3(a)(ii) One mark each: 3 • 1 get header with no parameter … • … returning attribute • Second correct get method Example program code: Java public Double GetIntelligence(){ return Intelligence; } public String GetName(){ return CharacterName; } VB.NET Function GetIntelligence() Return Intelligence End Function Function GetName() Return CharacterName End Function Python def GetIntelligence(self): return self.__Intelligence def GetName(self): return self.__CharacterName 3(a)(iii) One mark each 2 • Set header with 1 parameter … • … assigns parameter to attribute Example program code: Java public void SetIntelligence(Double NewValue){ Intelligence = NewValue; } VB.NET Sub SetIntelligence(NewValue) Intelligence = NewValue End Sub+ Python def SetIntelligence(self, NewValue): self.__Intelligence = NewValue 3(a)(iv) One mark for method multiplying attribute intelligence by 1.1 (or equivalent) and storing in attribute. 1 Example program code: Java public void Learn(){ Intelligence = Intelligence * 1.1; } VB.NET Overridable Sub Learn() Intelligence = Intelligence * 1.1 End Sub Python def Learn(self): self.__Intelligence = self.__Intelligence * 1.1 3(a)(v) One mark each 2 • Method (function) header (and end where appropriate) no parameter, returning a calculated age • Extracting attribute year of birth from date and subtracting from 2023 Example program code: Java public Integer ReturnAge(){ return 2023 - DateOfBirth.getYear(); } VB.NET Function ReturnAge() Return DateDiff(DateInterval.Year, DateOfBirth, #01/01/2023#) End Function Python def ReturnAge(self): return 2023 - self.__DateOfBirth.year 3(b)(i) One mark each: 2 • Creating new instance of Character with identifier FirstCharacter … • … sending correct values as parameters Example program code: Java Character FirstCharacter = new Character("Royal", new Date(2019,01,01), 70.0, 30); VB.NET Sub Main(args As String()) Dim FirstCharacter As Character FirstCharacter = New Character("Royal", #1/1/2019#, 70, 30) End Sub Python FirstCharacter = Character("Royal", datetime.datetime(2019, 1, 1), 70, 30) 3(b)(ii) One mark each 3 • Calling Learn() for FirstCharacter • Calling ReturnAge() and outputting return value • Outputting name and intelligence using gets with suitable message Example program code: Java FirstCharacter.Learn(); System.out.println(FirstCharacter.GetName() + " is " + FirstCharacter.ReturnAge() + " years old and has intelligence " + FirstCharacter.GetIntelligence()); VB.NET FirstCharacter.Learn() Console.WriteLine(FirstCharacter.GetName() & " is " & FirstCharacter.ReturnAge() & " years old and has intelligence " & FirstCharacter.GetIntelligence()) Python FirstCharacter.Learn() print(FirstCharacter.GetName(), "is", FirstCharacter.ReturnAge(), "years old and has intelligence" , FirstCharacter.GetIntelligence()) 3(b(iii) One mark for screenshot with Royal, 4 years, 77 intelligence e.g. 1 3(c)(i) One mark each: 5 • Class header inheriting from Character • Declaring Element as string • Constructor header taking 5 parameters … • … calling parent constructor with the 4 parameters • … assigning parameter to Element Example program code: Java class MagicCharacter extends Character{ private String Element; public MagicCharacter(String ElementP, String CName, Date DBirth, Double Intell, Integer SpeedP){ super(CName, DBirth, Intell, SpeedP); Element = ElementP; } } VB.NET Class MagicCharacter Inherits Character Private Element As String Sub New(ElementP, CName, DBirth, Intell, SpeedP) MyBase.New(CName, DBirth, Intell, SpeedP) Element = ElementP End Sub End Class 3(c)(i) Python class MagicCharacter(Character): #self.__Element String def __init__(self, ElementP, CName, DBirth, Intell, SpeedP): super().__init__(CName, DBirth, Intell, SpeedP) self.__Element = ElementP 3(c)(ii) One mark each: 3 • Method header overriding parent method but no parameters • Checking element value … • … correct calculations with attribute intelligence and storing Example program code: Java public void Learn(){ if(Element.equals("fire") || Element.equals("water")){ super.SetIntelligence(super.GetIntelligence() * 1.2); }else if(Element.equals("earth")){ super.SetIntelligence(super.GetIntelligence() * 1.3); }else{ super.SetIntelligence(super.GetIntelligence() * 1.1); } } VB.NET Overrides Sub Learn() If Element = "fire" Or Element = "water" Then SetIntelligence(GetIntelligence() * 1.2) ElseIf Element = "earth" Then SetIntelligence(GetIntelligence() * 1.3) Else SetIntelligence(GetIntelligence() * 1.1) End If End Sub 3(c)(ii) Python def Learn(self): if(self.__Element == "fire" or self.__Element == "water"): super().SetIntelligence(super().GetIntelligence() * 1.2) elif self.__Element == "earth": super().SetIntelligence(super().GetIntelligence() * 1.3) else: super().SetIntelligence(super().GetIntelligence() * 1.1) 3(d)(i) One mark each: 2 • Declaring MagicCharacter with identifier FirstMagic … • … with correct parameters Example program code: Java MagicCharacter FirstMagic = new MagicCharacter("fire", "Light", new Date(2018,03,03), 75.0, 22); VB.NET Dim FirstMagic As MagicCharacter FirstMagic = New MagicCharacter("fire", "Light", #3/3/2018#, 75, 22) Python FirstMagic = MagicCharacter("fire", "Light", datetime.datetime(2018, 3, 3), 75, 22) 3(d)(ii) One mark for calling Learn() for FirstMagic and outputting all required data in appropriate message using gets. 1 Example program code: Java FirstMagic.Learn(); System.out.println(FirstMagic.GetName() + " is " + FirstMagic.ReturnAge() + " years old and has intelligence " + FirstMagic.GetIntelligence()); VB.NET FirstMagic.Learn() Console.WriteLine(FirstMagic.GetName() & " is " & FirstMagic.ReturnAge() & " years old and has intelligence " & FirstMagic.GetIntelligence()) Python FirstMagic.Learn() print(FirstMagic.GetName(), "is", FirstMagic.ReturnAge(), "years old and has intelligence", FirstMagic.GetIntelligence()) 3(d)(iii) One mark for screenshot e.g. 1
What you needed in this session
Cambridge’s own grade thresholds for 2023 Oct/Nov, Paper 4 · Variant 2. A higher threshold means an easier paper — the bar moves with how the cohort did.