Final answer:
1. Point class:
```python
class Point:
def __init__(self, x, y):
self._x_coord = x
self._y_coord = y
def get_x_coord(self):
return self._x_coord
def get_y_coord(self):
return self._y_coord
def distance_to(self, other_point):
return ((self._x_coord - other_point.get_x_coord()) ** 2 + (self._y_coord - other_point.get_y_coord()) ** 2) ** 0.5
```
2. LineSegment class:
```python
class LineSegment:
def __init__(self, endpoint_1, endpoint_2):
self._endpoint_1 = endpoint_1
self._endpoint_2 = endpoint_2
def get_endpoint_1(self):
return self._endpoint_1
def get_endpoint_2(self):
return self._endpoint_2
def length(self):
return self._endpoint_1.distance_to(self._endpoint_2)
def is_parallel_to(self, other_line_segment):
return abs(self.slope() - other_line_segment.slope()) < 0.000001
def slope(self):
x1 = self._endpoint_1.get_x_coord()
y1 = self._endpoint_1.get_y_coord()
x2 = self._endpoint_2.get_x_coord()
y2 = self._endpoint_2.get_y_coord()
if x2 - x1 != 0:
return (y2 - y1) / (x2 - x1)
else:
return float('inf')
```
Step-by-step explanation:
For the Point class, it initializes two private data members `_x_coord` and `_y_coord` using the provided x and y coordinates in the `__init__` method. Two get methods, `get_x_coord` and `get_y_coord`, are created to access these private members. The `distance_to` method calculates the distance between two Point objects using the distance formula, utilizing the direct access of coordinates for the Point object the method is called on and the get methods for the coordinates of the Point passed as an argument.
In the LineSegment class, the `__init__` method initializes private data members `_endpoint_1` and `_endpoint_2` using the provided endpoints. The get methods `get_endpoint_1` and `get_endpoint_2` retrieve these endpoints. The `length` method calculates the distance between endpoints using the `distance_to` method from the Point class. `is_parallel_to` compares the slopes of two LineSegment objects by calculating slopes using the `slope` method. The `slope` method computes the slope between the endpoints by applying the slope formula considering different scenarios, like when the x-values are the same (vertical line). The `is_parallel_to` method checks for similarity in slopes within a threshold to determine if the LineSegments are parallel.