12 - Class Features
๐ง Properties, Methods, and Constructors ๐๏ธ
๐ง Properties, Methods, and Constructors ๐๏ธ
In this lesson we will:
Recall what we've learned so far
Discuss various features of classes (objects)
Properties
Methods
The Constructor
Table of Contents
Easy to define and use for combining multiple data into one usable variable.
Limited - you can only declare and use one at a time.
Open - you cannot hide or "protect" the data from being read or changed.
We created a Stack ADT to practice the concept.
Object Oriented Programming (OOP) is a completely different mindset to procedural programming.
Classes are designed using Class Diagrams, part of the Unified Modeling Language (UML).
They are a blueprint of a reproducible "object" - not usable until instantiated with the new keyword.
They can contain properties like .name, .age, and .alive
// A Playing Card
class PlayingCard {
ย ย value;
ย ย name;
ย ย suit;
ย ย colour;
ย ย is_face = false;
}
let card = new PlayingCard();
card.name = "Queen";
card.is_face = true;
Properties, Methods, and Constructors - Oh My!
Giving our objects functionality ๐ click for the repo
๐ฟ๏ธ