Let's Play with Numbers!!! Write the ComplexNumber class so that the following code generates the output below.

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter16: Graphics
Section: Chapter Questions
Problem 16RQ
icon
Related questions
Question

please solve  in python language and use proper command so I can understand. Thank you.

Task - 1
Let's Play with Numbers!!!
Write the ComplexNumber class so that the following code generates the output
below.
class Rea1Number:
OUTPUT:
RealPart: 1.0
ImaginaryPart: 1.0
_init_(self, r=0):
self._realValue
def getRealValue(self):
return self._realValue
def setRealValue(self, r):
def
= r
RealPart: 5.0
ImaginaryPart: 7.0
self._realValue
= r
def _str_(self):
return 'RealPart: '+str(self.getRealValue())
cn1 =
ComplexNumber()
print(cn1)
print('-
- ')
cn2 =
ComplexNumber(5,7)
print(cn2)
Transcribed Image Text:Task - 1 Let's Play with Numbers!!! Write the ComplexNumber class so that the following code generates the output below. class Rea1Number: OUTPUT: RealPart: 1.0 ImaginaryPart: 1.0 _init_(self, r=0): self._realValue def getRealValue(self): return self._realValue def setRealValue(self, r): def = r RealPart: 5.0 ImaginaryPart: 7.0 self._realValue = r def _str_(self): return 'RealPart: '+str(self.getRealValue()) cn1 = ComplexNumber() print(cn1) print('- - ') cn2 = ComplexNumber(5,7) print(cn2)
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT