Please enable JavaScript to use CodeHS

AP Computer Science A (Mocha)

Lesson 4.4 Writing Classes

Description

Now that students have had practice using classes without actually changing the source code for a class, they dive in and actually start writing our own classes. In this lesson, students will learn the basics of writing classes including implementing constructors, using instance variables, and writing a toString method.


Objective

Students will be able to:

  • Create their own class
  • Create a constructor for a class
  • Determine what instance variables a class should have and create them
  • Create a toString method for a class so that it can be printed out
  • Create a program that uses their own class as a client