Answered step by step
Verified Expert Solution
Question
1 Approved Answer
write this methods in python - Create a file named point, py. Create class Point, with a constructor (initializer) method that takes two integers, x
write this methods in python
- Create a file named point, py. Create class Point, with a constructor (initializer) method that takes two integers, x and y, and stores them as instance variables self.x and self.y. Please not that the file name and the class name are case-sensitive. When you have completed this step, test case test_initializing_a_point should pass. - 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 negative, the result will be decreasing self.x and/or self.y . When you have completed this step, the test case test_moving_ a point should pass. - Create 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, _eq__ should return true, otherwise, it should return false, When you have completed this step, both test cases test points_equality and test points_inequality should pass. - At this stage, 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 x component 10 and y component 12 to look like (10, 12). To accomplish this, you will define another special method called method takes only the self object as an argument, and it returns the preferred string representation of that object. - When you have completed these steps, all the test cases should passStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started