\newpage

\section{Class and object} % (fold)
\label{sec:class_and_object}

\subsection{Class} % (fold)
\label{sub:class}

 Object-oriented programming (OOP)  is a programming model based on the concept of objects. An object can be defined as a data table that has unique attributes and methods (operations) that define its behavior.
 
 \vspace{1em}
A class is essentially a user-defined data type. It describes the contents of the objects that belong to it. A class serves as a  blueprint  for creating objects, providing initial values for   attributes and implementations of methods\footnote{action which an object is able to perform.} cthat are common to all objects of a certain kind.
% subsection class (end)

\subsection{Object} % (fold)
\label{sub:object}
 An Object is an instance of a class. Each object contains attributes and methods. Attributes are information or object characteristics of the object stored in the data table (called fields), while methods define the object's behavior.
 
  \vspace{1em}
 All objects in the package are typed. The object types currently defined and used are: \tkzNameObj{point}, \tkzNameObj{line}, \tkzNameObj{circle}, \tkzNameObj{triangle}, \tkzNameObj{conic}, \tkzNameObj{quadrilateral}, \tkzNameObj{square}, \tkzNameObj{rectangle}, \tkzNameObj{parallelogram} and \tkzNameObj{regular\_polygon}. 

These objects can be created directly using the method \Imeth{obj}{new} by giving points, with the exception of the \Iclass{class}{point} class which requires a pair of reals, and \Iclass{class}{regular\_polygon} which needs two points and an integer.

 Objects can also be obtained by applying methods to other objects. For example, |T.ABC : circum_circle ()| creates an object \tkzNameObj{circle}. Some object attributes are also objects themselves, such as |T.ABC.bc| which creates the  \tkzNameObj{line} object, representing a straight line passing through the last two points defining the triangle.

 \vspace{1em}

 \subsubsection{Attributes} % (fold)
 \label{ssub:attributes}
 Attributes are accessed using the classic method, so |T.pc| retrieves the third point  of the triangle and |C.OH.center| retrieves the center of the circle.  Additionally, I've added  a |get_points| function that returns the points of an object. This function applies to straight lines (pa and pc), triangles (pa, pb and pc) and circles (center and through).

  \vspace{1em}
  Example: |z.O,z.T = get_points (C)| retrieves the center and a point of the circle.
 % subsubsection attributes (end)

\subsubsection{Methods} % (fold)
\label{ssub:methods}

A method is an operation (function or procedure) associated (linked) with an object.

Example:   The point object is used to vertically determine a new point object located at a certain distance from it (here 2). Then it is possible to rotate objects around it.

\begin{Verbatim}
\directlua{
      init_elements ()
      z.A = point (1,0)
      z.B = z.A : north (2)             
      z.C = z.A : rotation (math.pi/3,z.B)
      tex.print(tostring(z.C))
}
\end{Verbatim}

\directlua{
   init_elements ()
   z.A = point (1,0)
   z.B = z.A : north (2)
   z.C = z.A : rotation (math.pi/3,z.B)
   tex.print(tostring("The coordinates of $C$ are: " .. z.C.re .." and "..z.C.im))
}


% subsubsection methods (end)
% subsection object (end)
% section class_and_object (end)
\endinput