Page 1 of 1

Trajectory. (1) Create a class Trajectory. It has attributes xs and ys, which each store a List[float], indicating all c

Posted: Tue Jul 12, 2022 8:17 am
by answerhappygod
Trajectory 1 Create A Class Trajectory It Has Attributes Xs And Ys Which Each Store A List Float Indicating All C 1
Trajectory 1 Create A Class Trajectory It Has Attributes Xs And Ys Which Each Store A List Float Indicating All C 1 (51.71 KiB) Viewed 29 times
Trajectory. (1) Create a class Trajectory. It has attributes xs and ys, which each store a List[float], indicating all coordinates (x, y) that the object has ever been at. When creating a Trajectory, we shall provide the starting coordinate (x, y) of the object, like so: Exercise t = Trajectory (4.2, 5.1) (2) Create a method move to (x, y) that mutates the attributes so the object tracks where it has been: t.moveto (4.5, 6.2) t.moveto (4.3, 8.1) t.moveto (4.4, 6.0) t.xs [4.2, 4.5, 4.3, 4.4] t.ys [5.1, 6.2, 8.1, 6.0] (3) Create a method plot () that draws a plot of where the object has been. For example, t.plot() should draw a plot like the following: 8.0 7.5 7.0- 6.5 6.0 2 5.5 50 4.20 4.35 4.40 4.45 4.50 You may find it useful to implement additional magic methods such as repr_or_eq, but these will not be marked.