| 142 | |
| 143 | |
| 144 | class Complex: |
| 145 | def __init__(self, real, imag): |
| 146 | self.real = real |
| 147 | self.imag = imag |
| 148 | |
| 149 | def __repr__(self): |
| 150 | return "Com" + str((self.real, self.imag)) |
| 151 | |
| 152 | def __sub__(self, other): |
| 153 | return Complex(self.real - other, self.imag) |
| 154 | |
| 155 | def __rsub__(self, other): |
| 156 | return Complex(other - self.real, -self.imag) |
| 157 | |
| 158 | def __eq__(self, other): |
| 159 | return self.real == other.real and self.imag == other.imag |
| 160 | |
| 161 | |
| 162 | assert Complex(4, 5) - 3 == Complex(1, 5) |
no outgoing calls
no test coverage detected