Exercise 1

1 Using replaceable and redeclare on class Point

Point is a built-in type in Modelica.





Create a class
Redeclaration, containing a Point P as a variable. You should set the values of x, y and z as well.





In the class below you should redeclare
P as the type myPoint, which is a subtype of Point (you can write myPoint further below).





You can declare the class
myPoint here, below.



1.1 Hint

The variable P must be declared replaceable in class Redeclaration.


1.2

1.2.1 class Point


1.2.2 class Redeclaration


1.2.3 class MyPoint


1.2.4 class PointRed

myPoint is a subtype of Point, it changes type and prefix of P



1.2.5 Simulation of Redeclaration and PointRed



2 Question

If you instead had a class MyPoint with z as an Integer. Would that work?



2.1

No, because then MyPoint would not be a subclass of Point.