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})"

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education