Exercise 1

1 Question

Packages are nice to use in Modelica, but what exactly is a package?


A package is simply a container or namespace for names of classes, functions, constants, and other allowed definitions. A package is also one or the restricted classes.

2 Question

Why use the word encapsulated when creating packages?


Adding the word encapsulated to the package keeps the package well structured as well as being easier to understand and maintain.

3 Creating a Package

Create a package that contains a constant PI, a type Distance, a function RectangleArea, a function TriangleArea, a function CirclePerimeter and a function CircleArea.

Write a class,
GeometryUser, that uses the package and calls the functions.


3.1.1 package Geometry

3.1.2 GeometryUser

3.1.3 Simulation of GeometryUser