From e53c35223bed9a32f1e9cd3fe75caf344d4b5c7e Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Thu, 24 Apr 2025 17:37:21 -0600 Subject: Updated tex files --- book/module1/classes_and_objects.tex | 96 ++++++++++++++++++++++++++---------- 1 file changed, 71 insertions(+), 25 deletions(-) (limited to 'book/module1/classes_and_objects.tex') diff --git a/book/module1/classes_and_objects.tex b/book/module1/classes_and_objects.tex index cb9f7ec..b783048 100644 --- a/book/module1/classes_and_objects.tex +++ b/book/module1/classes_and_objects.tex @@ -13,29 +13,77 @@ or vehicles) \end{itemize} -\begin{longtable}[]{@{} - >{\raggedleft\arraybackslash}p{(\columnwidth - 0\tabcolsep) * \real{0.0556}}@{}} -\toprule\noalign{} -\begin{minipage}[b]{\linewidth}\raggedleft -\#\# 2. Core OOP Concepts - A. \textbf{Classes and Objects} - -Definitions - Syntax in Python - B. \textbf{Attributes and Methods} - -Instance variables - Functions inside classes - C. -\textbf{Encapsulation} - Public vs private variables - Using -\texttt{\_\_init\_\_} and \texttt{self} - D. \textbf{Inheritance} - -Parent and child classes - Reuse and extension of code - E. -\textbf{Polymorphism} \emph{(brief overview)} - Method overriding - -Flexibility in interfaces -\end{minipage} \\ -\midrule\noalign{} -\endhead -\bottomrule\noalign{} -\endlastfoot -\#\# 3. Python OOP Syntax and Examples - A. Define a simple class (e.g., -\texttt{Spring}) - B. Instantiate objects and use methods - C. Show -\texttt{\_\_init\_\_}, \texttt{\_\_str\_\_}, custom methods - D. Add a -derived class (e.g., \texttt{DampedSpring} inherits from -\texttt{Spring}) \\ -\end{longtable} +\subsection{2. Core OOP Concepts}\label{core-oop-concepts} + +\begin{itemize} +\tightlist +\item + A. \textbf{Classes and Objects} + + \begin{itemize} + \tightlist + \item + Definitions + \item + Syntax in Python + \end{itemize} +\item + B. \textbf{Attributes and Methods} + + \begin{itemize} + \tightlist + \item + Instance variables + \item + Functions inside classes + \end{itemize} +\item + C. \textbf{Encapsulation} + + \begin{itemize} + \tightlist + \item + Public vs private variables + \item + Using \texttt{\_\_init\_\_} and \texttt{self} + \end{itemize} +\item + D. \textbf{Inheritance} + + \begin{itemize} + \tightlist + \item + Parent and child classes + \item + Reuse and extension of code + \end{itemize} +\item + E. \textbf{Polymorphism} \emph{(brief overview)} + + \begin{itemize} + \tightlist + \item + Method overriding + \item + Flexibility in interfaces + \end{itemize} +\end{itemize} + +\subsection{3. Python OOP Syntax and +Examples}\label{python-oop-syntax-and-examples} + +\begin{itemize} +\tightlist +\item + A. Define a simple class (e.g., \texttt{Spring}) +\item + B. Instantiate objects and use methods +\item + C. Show \texttt{\_\_init\_\_}, \texttt{\_\_str\_\_}, custom methods +\item + D. Add a derived class (e.g., \texttt{DampedSpring} inherits from + \texttt{Spring}) +\end{itemize} \subsection{4. Engineering Applications of OOP}\label{engineering-applications-of-oop} @@ -57,8 +105,6 @@ OOP}\label{engineering-applications-of-oop} C. Organizing simulation code with OOP \end{itemize} -\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center} - \subsection{5. Hands-On Coding Activity}\label{hands-on-coding-activity} \begin{itemize} -- cgit v1.2.3