Exercise 1

1 Question

What does a modifier do?


1.1

A modifier modifies one or more declaration(s) from an inherited class by changing some aspect(s) of the inherited declarations.


2 Easy Example of Using Modifications

Modify
- the
start value to 3,
- the
min value to -22 and
- the
fixed value to true
of the variable
test in the class Test below.



Rewrite the class here.



2.1


3 Modifiers for Array Values

In this exercise you should modify different values of the following variables:
Set fixed to true in A1.
Set the start value to false in truthvalues.
Set unit to "kV" in the position: first row and second column of A2.
Set the start value on the first row in A3 to the values 3, 5 and 8. In the second row of the matrix the values should be set to 3, 10 and 22.
Set the matrix elements to "Pippi" in A4.



3.1 Hint

Remember that each attribute has the same dimensionality as the array itself.
Read more about predefined Types/Classes in "Introduction to Modelica ..." by Peter Fritzson.


3.2


4 Modification and Access Control

The class Mod, below, contains five variables. Are you allowed to modify all of them? Why/Why not?



4.1

You are allowed to modify the variables x, y and z, but not the variables w and s, since they are protected.