This module dives into the advanced Object-Oriented Programming techniques in Java, focusing on Composition, Encapsulation, and Polymorphism.
- Composition: Modeling "has-a" relationships by assembling objects from other objects, and exposing clean delegation methods.
- Encapsulation: Hiding data and simplifying interfaces to secure fields and prevent invalid state.
- Polymorphism: Runtime method dispatch, factory methods, class casting,
var, andinstanceofwith pattern matching. - Challenges: Hands-on practice combining composition, encapsulation, and polymorphism in real-world-style exercises.
In addition, Packages is covered as an extra topic:
- Packages: Organizing code into modular structures and controlling access through imports and package declarations.
The project is organized into several subfolders, each focusing on a specific topic:
- ComputerFactory/:
ComputerFactory: Composition in action — building a PC from a case, monitor, and motherboard, and understanding has-a vs. is-a.
- Encapsulation/:
Encapsulation: Data hiding, validation in constructors, and simplifying public interfaces from a basic to an enhanced Player class.
- Packages/:
Packages: Package declarations and import statements to structure and share code across namespaces.
- Polymorphism/:
Polymorphism: Movie subclasses, factory methods, runtime type inspection withinstanceofand pattern matching, casting, andvarusage.
- challenges/:
BedroomComposition: Composition practice modeling a bedroom from walls, ceiling, bed, and lamp.SmartKitchen: Modeling IoT kitchen appliances with composition and delegated work.Printer: Encapsulation challenge with toner levels and duplex printing.CarTypes: Polymorphism challenge building gas, electric, and hybrid car subclasses.BillsBurgerChallenge: OOP Master Challenge crafting a burger restaurant app with meal orders, deluxe burgers, and pricing.