Objective
Derived data (area, perimeter…) is not stored: it is computed when requested through a read-only property, so it never gets out of date if the measures change. The measures are validated in their setter.
Instructions
- Create
Rectanglewith the propertieswidthandheight(they must be greater than 0; otherwiseValueError) and the read-only propertiesarea,perimeterandis_square. - The first line has the number
nof rectangles; each following line haswidth heightintegers. ShowArea: a Perimeter: p Square: s(YesorNo), orInvalid dimensionsif a measure is not valid.
2
3 4
5 5
Area: 12 Perimeter: 14 Square: No
Area: 25 Perimeter: 20 Square: Yes
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise