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})"
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})"
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 20RQ
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
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.Recommended textbooks for you
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,