In the module point.py • Create class Point, with a constructor (initializer) method that takes two integers, completed this step, test case TO CanConstructPoint should succeed. • Add a method move that takes two integer arguments, dx and dy This method should increase self.x by dx and increase self.y by dy and y and stores them as instance variables self.x and self.y. When you have dx or dy are negative, the result will be decreasing self.x and/or self.y) When you have completed this step, test case T1 CanMovePoint should succeed. • Now test case T2 EqualMeansIdentical will be -= You can fix this by creating a method with the special name eg which takes, in addition to self, another Point object. This method should return a boolean. If the x and y fields of the self object and the other Point object are equal, should return True and otherwise, it should eq return False. • Now you have defined Point objects that can be created, moved, and compared for equality. But if you print a Point object, you will get a fairly unfriendly representation like Test case T3 string rep expects the string representation of a Point object with look like (10, 12) component 10 and y component 12 to method takes only the self object as an argument, and it To accomplish this, you will define another special method called _str The str returns the preferred string representation of that object. There are many ways you can produce this string, but I suggest using f-strings, e.g., f" ({self.x}, {self.y})"

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question
In the module point.py
Create class Point, with a constructor (initializer) method that takes two integers, x and
completed this step, test case TO CanconstructPoint should succeed.
Add a method move that takes two integer arguments, dx and dy. This method should increase self.x by dx and increase self.y by dy . (If dx or dy are
and stores them as instance variables self.x and self.y. When you have
negative, the result will be decreasing self.x and/or self.y.) When you have completed this step, test case T1 CanMovePoint should succeed.
• Now test case T2 EqualMeansIdentical will be --. You can fix this by creating a method with the special name
_eq
which takes, in addition to self, another Point
object. This method should return a boolean. If the x and y fields of the self object and the other Point object are equal,
should return True, and otherwise, it should
eq
return False.
Now you have defined Point objects that can be created, moved, and compared for equality. But if you print a Point object, you will get a fairly unfriendly representation like
<point.Point object at 0x10b8aabe0>. Test case T3 string rep expects the string representation of a Point object with x component 10 and y component 12 to
look like (10, 12). To accomplish this, you will define another special method called
str
The
str
method takes only the self object as an argument, and it
returns the preferred string representation of that object. There are many ways you can produce this string, but I suggest using f-strings, e.g., f" ({self.x}, {self.y})"
Transcribed Image Text:In the module point.py Create class Point, with a constructor (initializer) method that takes two integers, x and completed this step, test case TO CanconstructPoint should succeed. Add a method move that takes two integer arguments, dx and dy. This method should increase self.x by dx and increase self.y by dy . (If dx or dy are and stores them as instance variables self.x and self.y. When you have negative, the result will be decreasing self.x and/or self.y.) When you have completed this step, test case T1 CanMovePoint should succeed. • Now test case T2 EqualMeansIdentical will be --. You can fix this by creating a method with the special name _eq which takes, in addition to self, another Point object. This method should return a boolean. If the x and y fields of the self object and the other Point object are equal, should return True, and otherwise, it should eq return False. Now you have defined Point objects that can be created, moved, and compared for equality. But if you print a Point object, you will get a fairly unfriendly representation like <point.Point object at 0x10b8aabe0>. Test case T3 string rep expects the string representation of a Point object with x component 10 and y component 12 to look like (10, 12). To accomplish this, you will define another special method called str The str method takes only the self object as an argument, and it returns the preferred string representation of that object. There are many ways you can produce this string, but I suggest using f-strings, e.g., f" ({self.x}, {self.y})"
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Developing computer interface
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,