Skip to content

Instantly share code, notes, and snippets.

@DrPsyFi
Forked from rogerwschmidt/this-oop.md
Created March 28, 2018 16:34
Show Gist options
  • Save DrPsyFi/a276d5da13e0166e5e368516a762f09c to your computer and use it in GitHub Desktop.
Save DrPsyFi/a276d5da13e0166e5e368516a762f09c to your computer and use it in GitHub Desktop.

this and OOP Instructor Notes

Objectives

  • Create a model that includes properties, and actions that on the properties (get/set)
  • Explain what a class is and why they are useful
  • Create a simple class with only a constructor
  • Add methods to a class
  • Explain why getters and setters are useful, and add getters and setters to a class
  • Explain what a static method is, and add a static method to a class

Create a model that includes properties, and actions that on the properties (get/set)

  • As a class, lets model a backhoe, including properties and actions.
  • With your groups, model a house, including properties and actions.

What are classes and why are they useful?

  • With your group discuss what classes are and why they are useful

How do you create a simple class with only a constructor

  • On your slate, create a class name Person that has properties fname and lname that are passed in the constructor.

How do you add methods to a class

  • On your slate, add a method to the Person class named fullName() that returns the properties fname and lname concated.

Why are getters and setters useful, and how do you add them to a class

  • With your group, explain why getters and setters are useful
  • With your group, add getters and setters for fname, lname, and change fullName() to a getter

What is a static method, and how do you add a static method to a class?

  • With your group, explain why static method is useful
  • With your group, add a new property age, create setters and getters, and create a static method named getOldest that takes 2 Person objects and it returns the older Person
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment