Single lesson · Written for OCR A Level (H446)

Constructors and instantiation – OCR A Level Computer Science lesson (H446)

Students learn to write a constructor that sets attributes from parameters, and instantiate objects correctly in Python and OCR pseudocode.

Also in a bundle Object-Oriented Programming – OCR A Level Computer Science lessons (H446) 13 lessons for £45 · save 13% on buying separately

Lesson 3 of 13 in unit 12.6 Object-Oriented Programming, taught in Year 12, Spring 1. It answers one big question: What happens at the moment an object is created?

By the end, students can write a constructor that sets attributes from parameters, and instantiate objects correctly in Python and OCR pseudocode.

The Build (the main task)
Write the constructor for Fernhollow's Ticket class so that it sets the ticket type and price from parameters and the number of scans to 0, then instantiate an adult ticket costing £18.50 (6 marks).
Support version
A Parsons problem: the constructor's lines and the instantiation line given jumbled, with two lines that set constants as distractors.
Challenge
Write a second instantiation that would make the constructor fail, and explain how to make the constructor reject it.
Real-world link
Each ticket sold at Fernhollow's gate or online becomes a Ticket object the moment it is paid for.
Key words
Constructor, Instantiation and Initial, each with a definition, an icon and a common mix-up on the key vocabulary slide.
Misconceptions it tackles
“The class declaration is the constructor”; “A constructor sets attributes to fixed values or null, not to its parameters”.
OCR H446 specification
1.2.4 (e); 2.2.1 (f) (programming techniques: using object-oriented techniques when writing programs).

Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.

Students need computers for the main task.

Also sold in the Object-Oriented Programming unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.

An independent resource written for OCR A Level Computer Science (H446). It is not endorsed by OCR or Cambridge University Press & Assessment. Programming project (NEA) lessons teach general skills on a made-up example project and give supervised time, within JCQ's rules on the help a centre may give.

What's included

  • Slide deck (PowerPoint)
  • Lesson plan (Word)
  • Worksheet (Word)
  • Support worksheet with scaffolds (Word)
  • Single-teacher licence: use and adapt it with your own classes

More for A Level Computer Science

See all

Written for the specifications named. Not endorsed by or affiliated with any exam board.