Question 7
OCR Computer Science June 2018 Paper 1A level16 marks
On the specification
- (a)
- 1.2 Software and software development
- (b)(i)
- 2.2 Problem solving and programming
- (b)(ii)
- 2.2 Problem solving and programming
- (b)(iii)
- 1.2 Software and software development
- (c)
- 2.2 Problem solving and programming
- (d)
- 1.5 Legal, moral, cultural and ethical issues
Question text
7 A taxi firm is investigating replacing its drivers with self‑driving cars. (a) Explain why the self‑driving system will use a real‑time operating system. [3] (b) The code for the self‑driving system has been written using an object‑oriented programming language. It recognises obstacles in the road and then classifies them. The class for Obstacle is shown below. public class Obstacle private moving //Boolean value private distance //Real number given in metres private direction //Integer given as between 1 and 360 degrees public procedure new(givenMoving, givenDistance, givenDirection) moving=givenMoving distance=givenDistance direction=givenDirection endprocedure public procedure updateDistance(givenDistance) distance=givenDistance endprocedure endclass (i) Write a line of code to create an object called bollard of type Obstacle which is not moving and is 7.8 metres away in a direction of 8 degrees. [2] (ii) Describe an example of encapsulation in the class definition code above. [2] (iii) Describe the advantages of using encapsulation. [2] (c) The self‑driving program recognises people as a special type of obstacle and the class Person should inherit the methods and attributes of Obstacle. People are treated like other obstacles except: • when the updateDistance method is called, if the person is more than 2 metres away but is 5 metres (or less) away, the method Controls.beepHorn() is called. • when the person is 2 metres away (or closer), the method Controls.applyBrakes() is called as well as Controls.beepHorn(). Complete the class Person. class Person public procedure updateDistance(givenDistance) distance=givenDistance endprocedure endclass [5] (d) Give one advantage and one disadvantage to the customers of the taxi using self‑driving cars rather than drivers. Advantage Disadvantage [2]