Object Oriented Programming is a paradigm used in many languages, including: c++, java, JavaScript, and Python. It allows for programming code and data to be connected in an easy to use structure. This structure (called a class) allows for code re-use in many applications.

You have already seen classes and objects, when we were using the various methods, of strings, dates, random, and in many other places. When we follow a variable or a value by a period and then a name, we are accessing attributes or methods of that object.

Objectives

Upon completion of this chapter’s exercises, you should be able to:

  • Describe the concept of a class, an object, attributes of an object, and methods that act upon that object.
  • Create a class to describe a “real world” class of things.
  • Set and Use attributes from within an object’s initializer and other methods.
  • Implement methods to set default attribute value and to return a string representation of the object.
  • Use the concept of inheritance to extend a base class into a more specific or specialized class.