| 114 | |
| 115 | print("Example 8") |
| 116 | class BoundedResistance(Resistor): |
| 117 | def __init__(self, ohms): |
| 118 | super().__init__(ohms) |
| 119 | |
| 120 | @property |
| 121 | def ohms(self): |
| 122 | return self._ohms |
| 123 | |
| 124 | @ohms.setter |
| 125 | def ohms(self, ohms): |
| 126 | if ohms <= 0: |
| 127 | raise ValueError(f"ohms must be > 0; got {ohms}") |
| 128 | self._ohms = ohms |
| 129 | |
| 130 | |
| 131 | print("Example 9") |