Exercise 1

1 Question

What is a class?


1.1

A class is a fundamental unit of modeling in Modelica, providing the structure for an object. Classes can contain equations, where the computations are performed.


2 Creating a Class

Create a class, Add, that calculates the sum of two parameters, which are Integer numbers with given values.



2.1

Since x + y = sum is an equation and not an assignment, the equation can also be written as sum = x + y without changing the meaning of the equation.



2.1.1 Simulation of Add


When we have simulated the class Add, we can look at the values of the variables at a specific point in time by writing: val(variableName,time), here with time=0;.