Object-Oriented Programming Notes

Object-Oriented Programming (OOP)
Manages complexity and minimizes code duplication.

Class
A container for variables and methods.
Each class is its own 'type' defining attributes and behavior.
In OOP, it's a blueprint or model of something in the real world.
Example:
java public class Cat { private String name; private String breed; public void meow() { System.out.println("meoooow"); } }
Represents the idea of a cat with name and breed properties and a meow behavior.

Object
A specific instance of a class with actual values for its fields.
Class: blueprint; Object: the actual thing.
Example:
A Cat object can have name = "Fluffy" and breed = "Siamese".

Classes vs. Objects
Classes define what an object is and does.
Objects are instances of a class with actual values.
Example:
Class: Dog
Object: Your Labrador named Sparky

Creating an Object
Use the new keyword to instantiate an object.
Example:
Scanner console = new Scanner(System.in);
Example:
Cat firstCat = new Cat("Fluffy", "Siamese");

OOP Paradigm
Breaks down programs into multiple files, each defining the behavior of game objects.
Java files represent objects that can be used in larger programs.
Example:
Goomba class in a Mario game.
States (variables): sprite image, points worth, location.
Behaviors (methods): move right, move left.
Each Goomba object is an instance of the Goomba class with specific values for its fields.