In the code template below, you are given two classes: Point, which represents to a point in 2D space, and Line, which represents a set of collinear points. To get the distance between two points, we just use the Euclidean distance formula for 2D: d = V(#2 – #1)² + (y2 – y1)² The slope of a line given two points (x1.yı) and (x.y:) , is given by this formula: Y2 – Y1 m = To check if a point (x1.y1) lies in a line with slope m, we can just use the slope-intercept form given by: y - Y1 = m(x – 2) The first two Point objects in the points attribute of a Line instance would dictate its slope and intercept. Afterwards, an instance of your Line class should be able to add collinear points to points. You cannot remove the first two points in the points attribute of a Line instance. This is to retain its slope and intercept. Your tasks are: a. To complete the other methods in the Point and Line classes. b. To create instances of the Point class and create an instance of the Line class whose points contain are instances of the Point class that are collinear with each other. Input Format The first line contains an integer n, the number of lines to follow. The next n lines contain the 2D coordinate values of each point, with the following format: Constraints For simplicity, assume that all x and y values in Point objects are integers. Assume that there would be no inputs that would result to lines with an infinite slope. Assume that the input number n will always be greater than 2. Output Format We can override the_str_method in the Point class such that it retums the 2D coordinates in the fomat: (х.у). We can override the str method in the Line class such that it retums a string containing all the collinear points in the line. Sample Input: e, e 1, 1 3, -3 Sample Output: Instatiating a Line: [(0, 0), (1, 1)] Adding More Points: ((0, 0), (1, 1)] Adding Redundant Points: [(0, 0), (1, 1)] Trying to Remove Last Input Point: (6, 0), (1, 1)] Trying to Remove All Points: [(6, 0), (1, 1)]
In the code template below, you are given two classes: Point, which represents to a point in 2D space, and Line, which represents a set of collinear points. To get the distance between two points, we just use the Euclidean distance formula for 2D: d = V(#2 – #1)² + (y2 – y1)² The slope of a line given two points (x1.yı) and (x.y:) , is given by this formula: Y2 – Y1 m = To check if a point (x1.y1) lies in a line with slope m, we can just use the slope-intercept form given by: y - Y1 = m(x – 2) The first two Point objects in the points attribute of a Line instance would dictate its slope and intercept. Afterwards, an instance of your Line class should be able to add collinear points to points. You cannot remove the first two points in the points attribute of a Line instance. This is to retain its slope and intercept. Your tasks are: a. To complete the other methods in the Point and Line classes. b. To create instances of the Point class and create an instance of the Line class whose points contain are instances of the Point class that are collinear with each other. Input Format The first line contains an integer n, the number of lines to follow. The next n lines contain the 2D coordinate values of each point, with the following format: Constraints For simplicity, assume that all x and y values in Point objects are integers. Assume that there would be no inputs that would result to lines with an infinite slope. Assume that the input number n will always be greater than 2. Output Format We can override the_str_method in the Point class such that it retums the 2D coordinates in the fomat: (х.у). We can override the str method in the Line class such that it retums a string containing all the collinear points in the line. Sample Input: e, e 1, 1 3, -3 Sample Output: Instatiating a Line: [(0, 0), (1, 1)] Adding More Points: ((0, 0), (1, 1)] Adding Redundant Points: [(0, 0), (1, 1)] Trying to Remove Last Input Point: (6, 0), (1, 1)] Trying to Remove All Points: [(6, 0), (1, 1)]
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
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.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 4 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY