Add a member function movetoxy to move a point from the


Starting from the file point.py in this repository, add the following new features to it:

  • Add a member function "moveto(x,y)" to move a point from the current position to the new position (x,y). For example, suppose the object is p and its the current position is (3,4), set by:

p.setx(3)

p.sety(4)

p.moveto(44,56) would set the new location to be (44,56); a subsequent p.get() call would show the coordinates (44,56).

  • Add a member function "getdxdy()" to show the last displacement. For example, when the current position, say, (3,4) is updated to (10,9), either by the "move" member function or the "moveto" member function, the "getdxdy()" function will return (7,5) (x displacement: 10-3=7, y displacement: 9-4=5). You are likely to introduce new local variables (attributes) in the class to keep track of the current and last coordinates.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Add a member function movetoxy to move a point from the
Reference No:- TGS02511668

Now Priced at $20 (50% Discount)

Recommended (96%)

Rated (4.8/5)