00 Specimen Paper 2
00 Specimen Paper 2
00 Specimen Paper 2
COMPUTER SCIENCE
STANDARD LEVEL
PAPER 2
SPECIMEN PAPER
1 hour
INSTRUCTIONS TO CANDIDATES
14 pages
© International Baccalaureate Organization 2011
– 11 – SPEC/4/COMSC/SP2/ENG/TZ0/XX
A bus company operates in a local city. The bus company operates along fixed routes where there are
marked stops and sometimes bus shelters for people to wait in out of the weather. People (passengers) pay
the driver a specified fare for travel when they enter a bus.
There are many objects in this company, here are some of them:
Object Description
Bus A physical vehicle that carries passengers on a specific route and has a driver.
Passenger A person that travels on a bus.
Route A series of roads/streets the bus travels over from its start to its destination.
A named place on a route where people wait for a bus. May be a simple
Bus Stop
marker or may have a shelter and seats.
Driver A person qualified to drive a bus and trained to drive it over a given route.
These two objects have already been defined for the bus company:
BusRoute Bus
Integer: route Integer: id
String: start String: driver
setRoute(Integer: route) BusRoute: busRoute
setStart(String: start) setId(Integer: id)
Integer getRoute() setDriver(String: driver)
String getStart() setBusRoute(BusRoute: route)
String toString() Integer getId()
String getDriver()
BusRoute getBusRoute()
String toString()
Turn over
– 12 – SPEC/4/COMSC/SP2/ENG/TZ0/XX
D1. (a) Explain the term parameter variable, using an example from the code. [2]
(b) Describe one additional field that might have been included in the BusRoute object/class.
Include data types and sample data. [2]
showBusDrivers(buses, 1010);
(d) Construct the method showBusDrivers(Bus[] b, int n) which lists the drivers for
all buses with a route number less than or equal to the parameter variable (n). [6]
The company wishes to keep track of its drivers in more detail, including first and last name and
employee number – this is a 4-digit whole number.
Turn over
– 14 – SPEC/4/COMSC/SP2/ENG/TZ0/XX
(c) Explain how a programming team could benefit from an Object Oriented Design approach. [4]
Recall that a Bus Stop is one of many named places on a route where buses stop to pick up or
drop off passengers. It may or may not have a shelter to protect passengers from the weather.
The distance in km from the start point of the Bus Route is important information for planning.
(d) Design the Bus Stop Object using a simple object diagram. [3]
(e) Suggest how Bus Stop information for a given Bus Route instance could
be stored, giving both sample data and sample code fragments to show how it could
be implemented. [4]
D3. The company grows, offers more routes of different types and decides to use three different
types of bus:
• A bus that operates on busy city routes – the Urban Bus – has only a driver.
• A smaller bus that operates on longer country routes – it carries an additional person to
collect the fares.
• A van that can be used for heavy equipment deliveries rather than passengers – the Delivery
Van – it carries a co-driver and a helper.
These vehicles will have some things in common, such as a driver, and other elements
that are different, for example both Urban and Rural buses will operate on a fixed route
whereas the Delivery Van will take equipment to specified destinations (such as factories or
other businesses).
(a) Construct diagrams to show how you would re-design the Bus class to
implement inheritance. [8]
A method is required in the subclasses that returns the number of employees per vehicle.