Creating Record Objects and Calling Methods
Overview
In this lesson, students will learn how to create objects of a record type and call methods on these records.
Learning Objectives
- 1.1.D.1 Identify methods that are provided for a record.
- 1.1.D.2 Write and interpret calls to methods of a record.
Skills
- S1.D Explain the impact design has on data storage.
- S2.A Write program code and implement algorithms.
- S2.C Analyze an algorithm and program code for correctness.
Student Outcomes
Students will be able to:
- define a new record type;
- create a new object of the new record type;
- call methods on the new object.
Duration: 1 class period
Resources
Warm-up / Motivate
As students enter the room, provide them with an index card that contains descriptions for records. Have the students write the record.
Some example descriptions might be:
- Record to represent a City that contains the State/Province and Country.
- Record to represent a Student that contains their student id number, first name, and last name.
- Record to represent a Hurricane that contains the name of the hurricane, date it made landfall, and size (scale of 1 - 5).
If students need assistance, they can refer back to Learn: Introduction to Records
Learn
Either as a group or on their own, have students complete tutorial: Learn: Creating Objects of a Record and Calling Methods
Practice
Wrap-up / Extension
Have students revisit the Records they created when they entered the classroom. Have them complete the following:
- Identify the instance variables, constructor, and methods.
- Create an object of the record type.
- Write a call to one of the methods.