Further programming: paradigms, OOP, files and exceptions – A Level Computer Science (9618)
60 questions · page 2 of 4
Question text
13 The pseudocode algorithm below uses random file access to copy 50 records from a live file
CurrentResults.dat to a stored file StoredResults.dat one record at a time. It uses the
user-defined type StudentResult.
TYPE StudentResult
DECLARE LastName : STRING
DECLARE FirstName : STRING
DECLARE ExamGrade : STRING
ENDTYPE
If any grades are missing in CurrentResults.dat, the text "Missing grade" is added to the
ExamGrade field in StoredResults.dat
Complete this file handling pseudocode algorithm.
DECLARE Grade : StudentResult
DECLARE Position : INTEGER
…
OPENFILE "StoredResults.dat" FOR RANDOM
…
SEEK "CurrentResults.dat", Position
GETRECORD "CurrentResults.dat", Grade
IF Grade.ExamGrade = "" THEN
…
ENDIF
…
…
NEXT Position
CLOSEFILE "CurrentResults.dat"
CLOSEFILE "StoredResults.dat"
[5]
ĬÓĊ®Ġ´íÈõÏĪÅĊàû¸Ā×
,
,
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
ĬÍĊ®Ġ´íÈõÏĪÅĊÝüµĄ×
Question text
5
Complete the table by filling in the missing object-oriented programming (OOP) terms and
descriptions.
OOP term
Description
A method that accesses the value of a property.
…
A method that changes the value of a property.
…
…
Object
…
…
…
Method
…
…
[4]
Question text
11
The pseudocode algorithm below allows a user to input a new stock item. The random file is
searched for the next empty location in the file and the new item is inserted there.
A suitable message is displayed if the file is full.
Complete this pseudocode.
DECLARE Location : INTEGER
DECLARE NewStock : STRING
DECLARE CurrentStock : STRING
DECLARE Stored : BOOLEAN
DECLARE Max : INTEGER
←
100000
Max
←
FALSE
Stored
←
1
Location
…
OUTPUT "Enter the new item you wish to store: "
INPUT NewStock
WHILE NOT Stored AND Location <= Max
…
GETRECORD "StockList.dat", …
IF CurrentStock = "" THEN
… "StockList.dat", NewStock
←
TRUE
Stored
ELSE
←
Location + 1
Location
ENDIF
ENDWHILE
… THEN
OUTPUT "The new item has not been stored as the file was full."
ENDIF
CLOSEFILE "StockList.dat"
[5]
ĬÓĊ®Ġ´íÈõÏĪÅĊßú¸Ā×
Question text
3
A program stores data in a binary tree that is designed using Object‑Oriented Programming
(OOP).
The tree stores data in ascending numerical order, for example:
30
20
45
1
21
33
63
The class Node stores data about the nodes.
Node
NodeData : Integer
stores the node’s integer data
LeftNode : Node
stores the node that is stored to the left of the current
node, or a null value if there is no node to the left
RightNode : Node
stores the node that is stored to the right of the current
node, or a null value if there is no node to the right
Constructor()
initialises NodeData to its parameter value; initialises
LeftNode and RightNode to a null value
GetLeft()
returns LeftNode
GetRight()
returns RightNode
GetData()
returns NodeData
SetLeft()
takes an object of type Node as a parameter and stores
it in LeftNode
SetRight()
takes an object of type Node as a parameter and stores
it in RightNode
Write program code to declare the class Node and its constructor.
(a) (i)
Do not declare the other methods.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question3_J25.
Copy and paste the program code into part 3(a)(i) in the evidence document.
[4]
(ii)
Write program code for the three get methods.
Save your program.
Copy and paste the program code into part 3(a)(ii) in the evidence document.
[3]
The method SetLeft() takes an object of type Node as a parameter. The method
(iii)
stores the parameter in the attribute LeftNode
The method SetRight() takes an object of type Node as a parameter. The method
stores the parameter in the attribute RightNode
Write program code for SetLeft() and SetRight()
Save your program.
Copy and paste the program code into part 3(a)(iii) in the evidence document.
[3]
(b) Write the main program to declare five objects of type Node :
•
Node 1 with the data 10
•
Node 2 with the data 20
•
Node 3 with the data 5
•
Node 4 with the data 15
•
Node 5 with the data 7
Save your program.
Copy and paste the program code into part 3(b) in the evidence document.
[2]
(c) The class Tree stores the tree.
Tree
FirstNode : Node
stores the root node in the tree
Constructor()
initialises FirstNode to its parameter value
GetRootNode()
returns the node stored in FirstNode
Insert()
stores its parameter node in the correct position in the
tree
Write program code to declare the class Tree and its constructor.
(i)
Do not declare the other methods.
Use your programming language 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.
[2]
Write program code for GetRootNode()
(ii)
Save your program.
Copy and paste the program code into part 3(c)(ii) in the evidence document.
[1]
The method Insert() takes a node as a parameter and then searches the tree to find
(iii)
the position to insert the new node by:
•
checking whether the node’s data is less than or greater than the root node’s data
•
moving to the left node if the data is less than the root node’s data
•
moving to the right node if the data is greater than or equal to the root node’s data
•
repeating until the final position of the node is found and stores the node in that
position.
Write program code for Insert()
Save your program.
Copy and paste the program code into part 3(c)(iii) in the evidence document.
[6]
(d) The recursive procedure OutputInOrder() outputs the data stored in the binary tree in
ascending numerical order.
The procedure takes a Node object as a parameter and then:
•
checks if the left node is null. If there is a left node, the function calls itself with the left
node
•
outputs the data of the current node
•
checks if the right node is null. If there is a right node, the function calls itself with the
right node.
Write program code for OutputInOrder()
Save your program.
Copy an
Question text
3
A program stores data about animals using Object‑Oriented Programming (OOP).
The class Animal stores the data about animals.
Animal
Name : String
stores the name of the animal
Sound : String
stores the sound the animal makes
Size : Integer
stores the size of the animal as an integer between 1 (smallest)
and 10 (largest)
Intelligence : Integer
stores the intelligence of the animal as an integer between 1 (least)
and 10 (most)
Constructor()
initialises all attributes to its parameter values
Description()
returns a string message that contains the data from the attributes
Write program code to declare the class Animal and its constructor.
(a) (i)
Do not declare the other methods.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question3_J25.
Copy and paste the program code into part 3(a)(i) in the evidence document.
[4]
The method Description() creates and returns a string of the animal’s data in the
(ii)
format:
"The animal's name is " <Name> ", it makes a " <Sound> ", its size
is " <Size> " and its intelligence level is " <Intelligence>
For example:
The animal's name is Teddy, it makes a Bark, its size is 4 and its
intelligence level is 6
Write program code for Description()
Save your program.
Copy and paste the program code into part 3(a)(ii) in the evidence document.
[3]
(b) The class Parrot inherits from the class Animal
Parrot inherits the attributes from Animal and overrides the Description() method. The
additional attributes and methods in the class Parrot are:
Parrot
WingSpan : Integer
the width of the parrot’s wings to the nearest cm
NumberWords : Integer
the number of words the parrot can speak
Constructor()
calls the parent constructor using its parameter values;
initialises WingSpan and NumberWords to its parameter values
ChangeNumberWords()
takes an integer parameter and adds this to the number currently
in NumberWords
Write program code to declare the class Parrot, its constructor and the method
(i)
ChangeNumberWords()
Use your programming language 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(b)(i) in the evidence document.
[4]
The method Description() in the class Parrot creates and returns a string of the
(ii)
animal’s data in the format:
"The animal's name is " <Name> ", it makes a " <Sound> ", its size
is " <Size> " and its intelligence level is " <Intelligence> ". It
has a wingspan of " <WingSpan> "cm and can say " <NumberWords> "
words."
For example:
The animal's name is Chewie, it makes a Squawk, its size is 1 and
its intelligence level is 10. It has a wingspan of 30cm and can
say 29 words.
Write program code for Description()
Save your program.
Copy and paste the program code into part 3(b)(ii) in the evidence document.
[2]
(c) The class Wolf inherits from the class Animal
Wolf inherits the attributes from Animal and overrides the Description() method. The
additional attributes and methods in the class Wolf are:
Wolf
TerritorySize : Integer
stores the size of the area where the wolf lives, to the nearest
square mile
Constructor()
calls the parent constructor using its parameter values;
initialises TerritorySize to its parameter value
SetTerritorySize()
takes an integer parameter and adds this to the number currently
in TerritorySize
Write program code to declare the class Wolf, its constructor and the method
(i)
SetTerritorySize()
Use your programming language 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.
[4]
The method Description() in the class Wolf creates and returns a string of the
(ii)
animal’s data in the format:
"The animal's name is " <Name> ", it makes a " <Sound> ", its size
is " <Size
Question text
3
A program stores data in a linked list that is designed using Object‑Oriented Programming (OOP).
The class Node stores data about the nodes.
Node
TheData : Integer
stores the integer data
NextNode : Node
stores the next node in the linked list
Constructor()
initialises TheData to its parameter value, initialises NextNode
to a null value
GetData()
returns TheData
GetNextNode()
returns NextNode
SetNextNode()
takes an object of type Node as a parameter and stores it in
NextNode
Write program code to declare the class Node and its constructor.
(a) (i)
Do not declare the other methods.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question3_J25.
Copy and paste the program code into part 3(a)(i) in the evidence document.
[4]
(ii)
Write program code for the two get methods.
Save your program.
Copy and paste the program code into part 3(a)(ii) in the evidence document.
[3]
The method SetNextNode() takes an object of type Node as a parameter. The method
(iii)
stores the parameter in the attribute NextNode
Write program code for SetNextNode()
Save your program.
Copy and paste the program code into part 3(a)(iii) in the evidence document.
[2]
(b) The class LinkedList stores the linked list.
LinkedList
HeadNode : Node
stores the first node in the linked list
Constructor()
initialises HeadNode to a null value
InsertNode()
creates a new node using its integer parameter. Sets this
node as the new head node and updates NextNode
RemoveNode()
finds the first node that contains its integer parameter and
removes this node from the linked list
Traverse()
concatenates and returns the integer data in each node in
the linked list
Write program code to declare the class LinkedList and its constructor.
(i)
Do not declare the other methods.
Use your programming language 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(b)(i) in the evidence document.
[2]
The method InsertNode():
(ii)
•
takes an integer as a parameter
•
creates a new node with the parameter as the integer data
•
uses the new node’s method SetNextNode() to store the current HeadNode as
the next node
•
replaces HeadNode with the current node.
Write program code for InsertNode()
Save your program.
Copy and paste the program code into part 3(b)(ii) in the evidence document.
[4]
The method Traverse() concatenates the integer data from the nodes in the linked
(iii)
list, starting with the node stored in HeadNode. The method returns the final string with
each integer data separated with a space.
Write program code for Traverse()
Save your program.
Copy and paste the program code into part 3(b)(iii) in the evidence document.
[3]
The method RemoveNode() takes an integer parameter to search for and remove from
(iv)
the linked list.
The method first checks if the linked list is empty. If the linked list is empty the method
returns FALSE
If the linked list is not empty, the integer data in HeadNode is compared to the parameter.
If it matches the parameter, HeadNode is changed to store the next node.
If the parameter does not match, the nodes are followed until either:
•
the node with matching integer data is found. This node is removed, the appropriate
nodes updated and TRUE returned
or
•
none of the nodes contain matching integer data to the parameter. No nodes are
removed and FALSE is returned.
Write program code for RemoveNode()
Save your program.
Copy and paste the program code into part 3(b)(iv) in the evidence document.
[6]
The main program creates a new LinkedList object and uses the appropriate method
(c) (i)
to insert five nodes with the following integer data values in the order given:
10
20
30
40
50
The main program then:
•
calls Traverse()
•
removes the node containing the integer data 30 using Remov
Question text
3
(a) Describe circuit switching as a method of data transmission.
…
…
…
…
…
… [3]
(b) State one benefit and one drawback of circuit switching as a method of data transmission.
Benefit …
…
Drawback …
…
[2]
ĬÏĊ®Ġ´íÈõÏĪÅĊÞú¸þ×
Question text
9
A veterinary surgery wants to create a class for individual pets.
Some of the attributes required in the class are listed in the table.
Attribute
Data type
Description
PetID
STRING
unique ID assigned at registration
PetType
STRING
type of pet assigned at registration
telephone number of owner assigned at
OwnerTelephone
STRING
registration
DateRegistered
DATE
date of registration
(a) State one reason why the attributes would be declared as PRIVATE.
…
… [1]
(b) Complete the class diagram for Pet, to include:
•
an attribute and data type for the name of the pet
•
an attribute and data type for the name of the owner
•
a method to create a Pet object and set attributes at the time of registration
•
a method to assign a pet ID
•
a method to assign the date of registration
•
a method to return the pet name
•
a method to return the owner’s telephone number.
Pet
PetID
: STRING
PetType
: STRING
OwnerTelephone
: STRING
DateRegistered
: DATE
… : …
… : …
…
…
…
…
…
[5]
ĬÓĊ®Ġ´íÈõÏĪÅĊßüµĀ×
Question text
10 Objects and classes form the basic structure of Object‑Oriented Programming (OOP).
(a) Outline the structure of a class.
…
…
…
…
…
… [3]
(b) Give three differences between an object and a class.
1 …
…
…
2 …
…
…
3 …
…
…
[3]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞû¸þ×
Question text
3
(a) Describe circuit switching as a method of data transmission.
…
…
…
…
…
… [3]
(b) State one benefit and one drawback of circuit switching as a method of data transmission.
Benefit …
…
Drawback …
…
[2]
ĬÏĊ®Ġ´íÈõÏĪÅĊÝû¸þ×
Question text
9
A veterinary surgery wants to create a class for individual pets.
Some of the attributes required in the class are listed in the table.
Attribute
Data type
Description
PetID
STRING
unique ID assigned at registration
PetType
STRING
type of pet assigned at registration
telephone number of owner assigned at
OwnerTelephone
STRING
registration
DateRegistered
DATE
date of registration
(a) State one reason why the attributes would be declared as PRIVATE.
…
… [1]
(b) Complete the class diagram for Pet, to include:
•
an attribute and data type for the name of the pet
•
an attribute and data type for the name of the owner
•
a method to create a Pet object and set attributes at the time of registration
•
a method to assign a pet ID
•
a method to assign the date of registration
•
a method to return the pet name
•
a method to return the owner’s telephone number.
Pet
PetID
: STRING
PetType
: STRING
OwnerTelephone
: STRING
DateRegistered
: DATE
… : …
… : …
…
…
…
…
…
[5]
ĬÓĊ®Ġ´íÈõÏĪÅĊàùµĀ×
Question text
2
A computer program is designed to simulate horses doing show jumping. In show jumping, horses
jump over obstacles called fences. A horse successfully jumps a fence if it does not knock the
fence down.
The program is written using Object-Oriented Programming (OOP).
The class Horse stores data about the horses.
Horse
Name : STRING
stores the name given to the horse
MaxFenceHeight : INTEGER
stores the maximum height in cm that the horse can
jump, for example 132
PercentageSuccess : INTEGER
stores the percentage chance of a horse not knocking
down a fence, for example 70 represents a 70% chance
of jumping a fence successfully
initialises Name, MaxFenceHeight and
Constructor()
PercentageSuccess to its parameter values
GetName()
returns the name of the horse
GetMaxFenceHeight()
returns the maximum height the horse can jump
Success()
calculates and returns the percentage chance of a horse
successfully jumping a specific fence
Write program code to declare the class Horse and its constructor.
(a) (i)
Do not declare the other methods.
Use your programming language’s appropriate constructor.
All attributes must be private. If you are writing in Python, include attribute declarations
using comments.
Save your program as Question2_N24.
Copy and paste the program code into part 2(a)(i) in the evidence document.
[4]
The get methods GetName() and GetMaxFenceHeight() each return the relevant
(ii)
attribute.
Write program code for the get methods.
Save your program.
Copy and paste the program code into part 2(a)(ii) in the evidence document.
[3]
(b) The array Horses stores objects of type Horse.
(i)
The program has two horses:
•
The horse named ‘Beauty’ can jump a maximum height of 150 cm and has a success
percentage rate of 72%.
•
The horse named ‘Jet’ can jump a maximum height of 160 cm and has a success
percentage rate of 65%.
Write program code to:
•
declare the array, Horses, local to the main program with space for two Horse
objects
•
store the two horses described in the array
•
output the name of both Horse objects from the array.
Save your program.
Copy and paste the program code into part 2(b)(i) in the evidence document.
[5]
(ii)
Test your program.
Take a screenshot of the output.
Save your program.
Copy and paste the screenshot into part 2(b)(ii) in the evidence document.
[1]
(c) The class Fence stores data about the fences. Each fence has a height in cm and a risk
number.
The risk is a whole number between 1 and 5 inclusive. A risk of 1 means the fence is the
easiest type to jump. A risk of 5 means the fence is the hardest type to jump.
Fence
Height : INTEGER
stores the height of the fence in cm
the height is between 70 and 180 inclusive
Risk : INTEGER
stores the risk as a whole number between 1 and 5
inclusive
initialises Height and Risk to its parameter values
Constructor()
GetHeight()
returns the height of the fence
GetRisk()
returns the risk of the fence
Write program code to declare the class Fence, its constructor and get methods.
(i)
Use your programming language’s appropriate constructor.
All attributes must be private.
If you are writing in Python, include attribute declarations using comments.
Save your program.
Copy and paste the program code into part 2(c)(i) in the evidence document.
[4]
The array Course stores four Fence objects. The user inputs the height and risk for
(ii)
each fence, and these are validated before each fence is created.
Amend the main program to:
•
declare the local array Course
•
take as input the data for four fences from the user
•
loop the input until both the height and risk are valid for each fence
•
create an instance of Fence for each of the four valid fences and store each
instance in the array.
Save your program.
Copy and paste the program code into part 2(c)(ii) in the evidence document.
[5]
(d) The chance of a horse jumping a fence without knocking it down is calculated as follows.
If the height of the fence is more than the maxi
Question text
1
A computer game is designed for users to select characters. Each character can take part in a
group of events. Each group has five events. There are four types of event: jump, swim, run, drive.
The program is written using object-oriented programming.
(a) The class EventItem stores data about the events.
EventItem
EventName : STRING
stores the name of the event
Type : STRING
stores the type of event, either: jump, swim, run or drive
Difficulty : INTEGER
stores the difficulty of the event from 1 (easiest) to 5
(hardest)
Constructor()
initialises EventName, Type and Difficulty to its
parameter values
GetName()
returns the name of the event
GetDifficulty()
returns the difficulty of the event
GetEventType()
returns the type of event
Write program code to declare the class EventItem and its constructor.
(i)
Do not declare the other methods.
Use your programming language’s appropriate constructor.
All attributes must be private.
If you are writing in Python, include attribute declarations, using comments.
Save your program as Question1_N24.
Copy and paste the program code into part 1(a)(i) in the evidence document.
[4]
The get methods GetName(), GetDifficulty() and GetEventType() each return
(ii)
the relevant attribute.
Write program code for the three get methods.
Save your program.
Copy and paste the program code into part 1(a)(ii) in the evidence document.
[3]
(b) The array Group stores five objects of type EventItem.
Write program code to declare Group local to the main program.
(i)
Save your program.
Copy and paste the program code into part 1(b)(i) in the evidence document.
[1]
(ii)
One group has the following events:
Event name
Event type
Event difficulty
Bridge
jump
3
Water wade
swim
4
100 mile run
run
5
Gridlock
drive
2
Wall on wall
jump
4
Write program code to create an instance of EventItem for each of the five events, and
store them in Group.
Save your program.
Copy and paste the program code into part 1(b)(ii) in the evidence document.
[3]
(c) The class Character stores data about the characters in the game.
Each character has a skill level for each type of event. The skill level is an integer between
1 and 5 inclusive. Skill level 1 is the lowest skill level, and skill level 5 is the highest skill level.
Character
CharacterName : STRING
stores the name of the character
Jump : INTEGER
stores the character’s skill level at events of type jump
Swim : INTEGER
stores the character’s skill level at events of type swim
Run : INTEGER
stores the character’s skill level at events of type run
Drive : INTEGER
stores the character’s skill level at events of type drive
Constructor()
initialises CharacterName, Jump, Swim, Run and
Drive to its parameter values
GetName()
returns the name of the character
CalculateScore()
takes the type of event and difficulty as parameters.
Calculates and returns the chance of the character
completing the event
Write program code to declare the class Character, its constructor and get method.
Use your programming language’s appropriate constructor.
All attributes must be private.
If you are writing in Python, include attribute declarations, using comments.
Save your program.
Copy and paste the program code into part 1(c) in the evidence document.
[4]
(d) The method CalculateScore() in the Character class calculates and returns the
percentage chance of a character completing an event.
When a character’s skill level is greater than or equal to the difficulty of that event, the
percentage chance of completing the event is 100%.
When a character’s skill level is less than the difficulty of that event, the character’s skill level
is subtracted from the difficulty of that event. This difference is used to identify the percentage
chance of success using this table:
Percentage chance
Difference
of success
1
80
2
60
3
40
4
20
For example:
•
A character has a skill level of 3 for events of type run.
•
An event of type run has a difficulty level of 5
•
The
Question text
8
A declarative programming language is used to represent the features that are available and the
features that are unavailable on different body styles of a car.
01
feature(sunroof).
02
feature(automatic_tailgate).
03
feature(heated_seats).
04
feature(extra_seats).
05
feature(reversing_camera).
06
feature(dashboard_camera).
07
feature(air_conditioning).
08
feature(heated_windscreen).
09
feature(satnav).
10
bodystyle(saloon).
11
bodystyle(hatchback).
12
bodystyle(estate).
13
bodystyle(minivan).
14
bodystyle(convertible).
15
available(sunroof, hatchback).
16
available(sunroof, minivan).
17
available(reversing_camera, hatchback).
18
available(extra_seats, minivan).
19
available(reversing_camera, saloon).
20
unavailable(sunroof, convertible).
21
unavailable(automatic_tailgate, saloon).
22
unavailable(extra_seats, hatchback).
These clauses have the meanings:
Clause
Meaning
01
Sunroof is a feature.
10
Saloon is a body style.
15
Sunroof is available on a hatchback.
20
Sunroof is unavailable on a convertible.
(a) Sliding doors is a feature that is available on a minivan but unavailable on a hatchback.
Write additional clauses to represent this information.
23 …
24 …
25 …
[3]
(b) Using the variable Options, the goal:
available(Options, saloon)
returns
Options = reversing_camera
Write the result returned by the goal:
available(Options, hatchback)
Options = … [1]
(c) F may be available for B if F is a feature and B is a body style and F is not unavailable for that
body style.
Write this as a rule:
may_choose_option(F, B)
IF …
…
…
… [4]
Question text
10 A declarative programming language is used to allow clients to choose daily activities at the
beach.
01
activity(paddleboarding).
02
activity(sailing).
03
activity(rowing).
04
activity(kayaking).
05
activity(jetskiing).
06
client(stevie).
07
client(antonio).
08
client(henry).
09
client(eliza).
10
client(rebeka).
11
client(danny).
12
client(erik).
13
client(simone).
14
client(petra).
15
client(frankie).
16
choice(petra, rowing).
17
choice(frankie, sailing).
18
choice(erik, sailing).
19
choice(eliza, rowing).
20
choice(stevie, jetskiing).
21
choice(henry, sailing).
22
done(henry, jetskiing).
23
done(rebeka, jetskiing).
24
done(antonio, kayaking).
These clauses have the meanings:
Clause
Meaning
01
Paddle boarding is an activity.
06
Stevie is a client.
16
Petra has chosen rowing.
22
Henry has already done jet skiing.
(a) Jane is a client who would like to choose the activity surfing and she has already done sailing.
Write additional clauses to represent this information.
25 …
26 …
27 …
28 …
[4]
(b) Using the variable List, the goal:
choice(List, rowing)
returns
List = petra, eliza
Write the result returned by the goal:
choice(List, sailing)
List = … [1]
(c) C is a client who would like to choose A if A is an activity and C has not already done A.
Write this as a rule:
may_choose_activity(C, A)
IF …
…
…
… [4]