model exempleFigures import Modelica.Utilities.Streams.print; type uneTaille = Real; class uneFigure Real x, y; // point de reference //replaceable function taille = tailleIndefinie; //replaceable function descriptionSIG = descriptionFigureSIG; //descriptionFigureSIG description = descriptionFigure; end uneFigure; function tailleIndefinie input uneFigure figure; output Real taille; algorithm taille := -1; end tailleIndefinie; /* partial function descriptionFigureSIG replaceable class FIG = uneFigure; input FIG figure; output String description; end descriptionFigureSIG; function descriptionFigure extends descriptionFigureSIG; algorithm description := descriptionNature(figure)+"\n" + descriptionReference(figure)+"\n" + descriptionTaille(figure); end descriptionFigure; function descriptionNature input uneFigure figure; output String description; algorithm description := "nature"; end descriptionNature; function descriptionReference input uneFigure figure; output String description; algorithm description := "reference en ("+String(figure.x)+", "+String(figure.y)+")"; end descriptionReference; function descriptionTaille input uneFigure figure; output String description; algorithm description := "taille = "+String(-1); end descriptionTaille; */ /* class unPoint extends uneFigure(redeclare function taille = unPoint.tailleNulle); function tailleNulle extends uneFigure.tailleSIG; algorithm taille := 0; end tailleNulle; end unPoint; */ /* partial class uneFigurePlane extends uneFigure(redeclare function taille = surface); replaceable function surface = uneFigurePlane.surfaceSIG; partial function surfaceSIG replaceable class FIGPLA = uneFigurePlane; input FIGPLA figure; output uneTaille surface; end surfaceSIG; end uneFigurePlane; class unCercle extends uneFigurePlane(redeclare function surface = unCercle.surface); Real rayon; function surface import Modelica.Constants.pi; extends surfaceSIG(redeclare class FIGPLA = unCercle); algorithm surface := pi*figure.rayon; end surface; end unCercle; */ /* class unRectangle extends uneFigure; end unRectangle; */ uneFigure f(x=-1,y=1/*,redeclare function taille=uneFigure.tailleIndefinie*/); //unCercle c1(x=1,y=2,rayon=3), c2(x=2,y=3,rayon=2); //unPoint p(x=-1, y=1); algorithm print(String(tailleIndefinie(f))); //print(String(c1.taille(c1))); //print(String(c2.taille(c2))); //print(String(p.taille(p))); end exempleFigures;