Unit 2: Using Objects

Unit 2: Using Objects

In the first unit, students used primitive types to represent real-world data and determined how to use them in arithmetic expressions to solve problems. This unit introduces a new type of data: reference data. Reference data allows real-world objects to be represented in varying degrees specific to a programmer’s purpose. This unit builds on students’ ability to write expressions by introducing them to Math class methods to write expressions for generating random numbers and other more complex operations. In addition, strings and the existing methods within the String class are an important topic within this unit. Knowing how to declare variables or call methods on objects is necessary throughout the course but will be very important in Units 5 and 9 when teaching students how to write their own classes and about inheritance relationships.


ESSENTIAL QUESTIONS

Modularity [MOD]

How can we simulate election results using existing program code?

Variables [VAR]

How are appropriate variables chosen to represent a remote control?

Control [CON]

How do the games we play simulate randomness?


BIG IDEAS

+ Objects and classes as ways to describe instances, attributes, and behaviors

+ Creating objects by calling constructors with and without parameters

+ Utilizing class libraries, including Integer and Double

+ Defining an object’s behavior using methods, including static and Math class

+ Calling non-static void methods with and without parameters

+ Using String objects and methods

+ Using application program interfaces (APIs) and libraries


UNIT TOPICS & ACTIVITIES

2.1: Objects: Instances of Classes

Lab: My Password App

2.2: Creating and Storing Objects (Instantiation)

Lab: My Screensaver

2.3: Calling a void Method

Lab: My Screensaver V2

2.4: Calling a void Method with Parameters

2.5: Calling a Non-void Method

2.6: String Objects: Concatenation, Literals, and More

2.7: String Methods

2.8: Wrapper Classes: Integer and Double

2.9: Using the Math Class


Link to Brainscapes

SKILLS ADDRESSED


Program Design and Algorithm Development

1.B: Determine code that would be used to complete code segments.

1.C: Determine code that would be used to interact with completed program code.

Code Logic

2.A: Apply the meaning of specific operators.

2.C: Determine the result or output based on the statement execution order in a code segment containing method calls.

Code Implementation

3.A: Write program code to create objects of a class and call methods.

Documentation

5.A: Describe the behavior of a given segment of program code