diff --git a/lab2/zad3/src/GF.st b/lab2/zad3/src/GF.st index ae3b88b..b4ca62e 100644 --- a/lab2/zad3/src/GF.st +++ b/lab2/zad3/src/GF.st @@ -23,12 +23,14 @@ Object subclass: GF [ ifTrue: [Error signal: 'both arguments must have the same characteristic'] ] + "throws Error on different characteristics" + rhs [ self verifyCharacteristics: rhs. ^GF create: characteristic withValue: ((value + rhs value) \\ characteristic) ] + "throws Error on different characteristics" - rhs [ self verifyCharacteristics: rhs. "^GF create: characteristic @@ -46,12 +48,15 @@ Object subclass: GF [ ]. ] + "throws Error on different characteristics" * rhs [ self verifyCharacteristics: rhs. ^GF create: characteristic withValue: ((value * rhs value) \\ characteristic) ] + "throws ZeroDivide on division by 0" + "throws Error on different characteristics" / rhs [ | inverse | self verifyCharacteristics: rhs. @@ -67,44 +72,53 @@ Object subclass: GF [ withValue: ((value * inverse) \\ characteristic) ] + "throws Error on different characteristics" = rhs [ self verifyCharacteristics: rhs. ^value = rhs value ] + "throws Error on different characteristics" ~= rhs [ self verifyCharacteristics: rhs. ^value ~= rhs value ] + "throws Error on different characteristics" > rhs [ self verifyCharacteristics: rhs. ^value > rhs value ] + "throws Error on different characteristics" < rhs [ self verifyCharacteristics: rhs. ^value < rhs value ] + "throws Error on different characteristics" >= rhs [ self verifyCharacteristics: rhs. ^value >= rhs value ] + "throws Error on different characteristics" <= rhs [ self verifyCharacteristics: rhs. ^value <= rhs value ] - + + "returns the characteristic of `self`" characteristic [ ^characteristic ] + "returns the value of `self`" value [ ^value ] + "prints `self` in a pretty format" displayOn: stream [ 'GF<' displayOn: stream. characteristic displayOn: stream.