From aa047a8826c03a38f0325353396ed95966c07d21 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Thu, 10 Apr 2025 12:43:05 -0600 Subject: Updated module 1 --- tutorials/module_1/1_classes_and_objects.md | 45 +++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'tutorials/module_1/1_classes_and_objects.md') diff --git a/tutorials/module_1/1_classes_and_objects.md b/tutorials/module_1/1_classes_and_objects.md index 0392483..ec85633 100644 --- a/tutorials/module_1/1_classes_and_objects.md +++ b/tutorials/module_1/1_classes_and_objects.md @@ -1,8 +1,47 @@ # Modular Programming -Classes and Objects +## 1. Introduction -## What are they? +- A. What is Object-Oriented Programming? +- B. Why use OOP? (vs. procedural) +- C. Real-world analogies (e.g., modeling components like pumps, motors, or vehicles) +--- +## 2. Core OOP Concepts +- A. **Classes and Objects** + - Definitions + - Syntax in Python +- B. **Attributes and Methods** + - Instance variables + - Functions inside classes +- C. **Encapsulation** + - Public vs private variables + - Using `__init__` and `self` +- D. **Inheritance** + - Parent and child classes + - Reuse and extension of code +- E. **Polymorphism** _(brief overview)_ + - Method overriding + - Flexibility in interfaces + +--- +## 3. Python OOP Syntax and Examples +- A. Define a simple class (e.g., `Spring`) +- B. Instantiate objects and use methods +- C. Show `__init__`, `__str__`, custom methods +- D. Add a derived class (e.g., `DampedSpring` inherits from `Spring`) + +--- +## 4. Engineering Applications of OOP +- A. Modeling a mechanical system using classes + - Example: Mass-Spring-Damper system +- B. Creating reusable components (e.g., `Material`, `Beam`, `Force`) +- C. Organizing simulation code with OOP + +--- +## 5. Hands-On Coding Activity +- A. Write a class for a basic physical component (e.g., `Motor`) +- B. Add behavior (e.g., `calculate_torque`) +- C. Extend with inheritance (e.g., `ServoMotor`) +- D. Bonus: Integrate two objects to simulate interaction -## Why do we care? -- cgit v1.2.3