
samples.methods.abstract.pec Maven / Gradle / Ivy
define perimeter as Decimal attribute
define Shape as category with attribute perimeter
define Square as Shape
define Circle as Shape
define printShape as abstract method receiving Shape shape
define printShape as method receiving Square shape doing:
printLine "Square side is " + (shape.perimeter / 4)
define printShape as method receiving Circle shape doing:
printLine "Circle radius is " + (shape.perimeter / (2 * 3.14159))
define main as method doing:
s = Square with 40.0 as perimeter
c = Circle with 40.0 as perimeter
shapes = [ s as Shape, c as Shape ]
for each ss in shapes:
printShape with ss as shape
© 2015 - 2025 Weber Informatics LLC | Privacy Policy