0% found this document useful (0 votes)
15 views

Unit 5 Lesson 02 Writing Constructors Lesson Plan

Uploaded by

shuguang liao
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Unit 5 Lesson 02 Writing Constructors Lesson Plan

Uploaded by

shuguang liao
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Lesson Plan

Lesson 5.2: Writing Constructors

Overview
This lesson explains the purpose of a constructor. Students will learn
how to write a no-argument constructor and constructors which
accept parameters. Students will also be challenged to write an entire
class, including instance variables, constructors, and a print method.

Student Learning Objectives


ENDURING UNDERSTANDING

MOD-2: Programmers use code to represent a physical object or


nonphysical concept, real or imagined, by defining a class based on the
attributes and/or behaviors of the
object or concept.

LEARNING OBJECTIVE ESSENTIAL KNOWLEDGE

MOD-2.B: Define instance variables ➢ MOD-2.B.1: An object’s state


for refers to its attributes and their
the attributes to be initialized values at a given time and is
through the constructors of a class. defined by instance variables
belonging to the object. This
creates a “has-a” relationship
between the object and its
instance variables.
➢ MOD-2.B.2: Constructors are used
to set the initial state of an
object, which should include
initial values for all instance
variables.
➢ MOD-2.B.3: Constructor
parameters are local variables to
the constructor and provide data
to initialize instance variables.
➢ MOD-2.B.4: When a mutable
object is a constructor parameter,
the instance variable should be
initialized with a copy of the
referenced object. In this way,
the instance variable is not an

1
Lesson Plan
Lesson 5.2: Writing Constructors

alias of the original object, and


methods are prevented from
modifying the state of the original
object.
➢ MOD-2.B.5: When no constructor
is written, Java provides a no-
argument constructor, and the
instance variables are set to
default values.

Materials and Resources


● Presentation system (LCD projector/Interactive whiteboard)
● 5.2 Writing Constructors in the CSAwesome e-book
● Programming Challenge 5.2 Student Class Worksheet (KEY)
● Writing Constructors Homework Worksheet (KEY)
● Alternative Worksheet Creating and Storing Objects:
Constructors (KEY)
● CSAwesome Programming Solutions

Learning Activities

Estimated Length: 45 min

● Hook/Motivation (10 mins):


○ As students enter class, hand each student a small/half piece of
paper
○ Ask students to read the opening paragraphs of the Runestone
5.2 Writing Constructors lesson (stop when they reach the
“Check Your Understanding” questions)
○ During, or after, reading the lesson opener, ask students to write
down one summary statement/fact about constructors and, if
possible, one question they have about constructors

○ Make Student Thinking Visual/Audible: Ask students to


share their facts about constructors as you add their ideas to the
board making a graphic organizer, such as a concept map, for all
to see. If possible, save the final graphic to post or share
digitally with students.

2
Lesson Plan
Lesson 5.2: Writing Constructors
○ Collect student papers and ensure all their questions are
eventually addressed in the lesson. If time, use these questions
at the end of the lesson during reflection time
● Experiences and Explorations (30 mins):
○ Ask students to complete the Check Your Understanding 5-2-1
and 5-2-2
○ ActiveCode 1 - Fraction Class
■ Have students work in pairs to look at the Fraction class
and predict the output BEFORE running the code
■ Allow them to run the code and discuss with their partner
about any differences between their predictions and the
actual output
■ Call on 2-3 students to share anything learned about their
output
○ Independent Practice: Have students complete ActiveCode 2
for the Car class to complete the two constructors and write the
code in the main method to create two Car objects, then show
solutions and ask for students to share any similarities or
differences between their code and teacher’s solution.

○ POGIL / Collaborative Group work: Have students work in


pairs to complete the Programming Challenge 5.2 Student Class
Worksheet (KEY) then enter code for the Programming Challenge
to write the Student class on the Runestone site. Have them do
the AP Practice questions.
○ Design a Class for your Community Challenge: Have the
students work in their original pairs to improve their class for
their community challenge from the last lesson. (possible
solution).
● Rethink, Reflect, and/or Revise (5 mins):
○ Give the Writing Constructors Homework Worksheet (KEY) to
students for homework.
○ If time, they can begin on the worksheet in class or teacher can
review student questions from the warm-up activity. Read a
student question aloud and call on a student for the answer to
check their understanding.

Check for Understanding


● Interactive Exercises: 5-2-1 - 5-2-4
● Coding Exercises: ActiveCode 1, Active Code 2, and Programming
Challenge: Student Class (ActiveCode 3)
● Pair Work: Programming Challenge Student Class Worksheet

3
Lesson Plan
Lesson 5.2: Writing Constructors
● Student Questions: Review Exit activity to reflect on student
questions they wrote during opening activity
● Homework: Writing Constructors Homework Worksheet
● Common Misconceptions:
○ Students may try to give a return type or “void” in the
constructor’s header
○ When assigning parameter values to instance variables, students
often confuse which variable is being assigned a value and which
variable contains the value to be assigned (i.e. n = name;
instead of name = n;)
● Personal Progress Check (College Board): The College Board AP
Classroom provides a quiz bank and Personal Progress Checks. You
may create a formative assessment quiz for topic 5.2 in the AP
Classroom. Review the results in class to identify and address any
student misunderstandings.

Differentiation: More Practice


● Practice-It Chapter 8: Self-Check 8.17-8.21 Use these Practice-It
questions which ask for details about what constructors are, correct
syntax of constructors, and how to use parameters to initialize instance
variables.

Differentiation: Enrichment
● BeginnersBook: Constructors in Java - A Complete Study! Use this
reference for a thorough explanation of constructors along with examples.

Background Knowledge
● I’d Rather Be Writing - Java Constructors
● Oracle Java Tutorials - Providing Constructors for Your Classes

Teaching Tips
● CSP → CS A Tips
○ In Mobile CSP, specifically, objects were created in MIT App
Inventor by dragging items from the Palette into the Viewer while

4
Lesson Plan
Lesson 5.2: Writing Constructors
in the Designer View. Therefore, it was not necessary to include
any code for constructing an object.
○ Light and dark green puzzle pieces hold or set the values of
properties (instance variables), and purple blocks were actions
(like object methods).
● Tips for Encouraging Help Seeking

Teacher Professional Development Reflection


After reviewing this lesson in professional development, complete the form
found here to provide feedback on the lesson, materials provided, etc.

You might also like