Package car_sim :: Module location :: Class Location
[hide private]
[frames] | no frames]

Class Location

object --+
         |
        Location

The class Location describes points on a two-dimensional surface. A location is defined by its two coordinates, and is immutable after creation.

Instance Methods [hide private]
 
__init__(self, x_coordinate, y_coordinate)
Initializes a new location with the given coordinates.
float
get_x_coordinate(self)
Returns the x-coordinate of the location
float
get_y_coordinate(self)
Returns the y-coordinate of the location.
float
get_distance(self, another_location)
Returns the distance between this location and another given location.
string
__str__(self)
Returns a description of the form (X, Y) of the location.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, x_coordinate, y_coordinate)
(Constructor)

 

Initializes a new location with the given coordinates.

Parameters:
  • x_coordinate (float) - the x-coordinate of the location
  • y_coordinate (float) - the y-coordinate of the location
Overrides: object.__init__

get_x_coordinate(self)

 

Returns the x-coordinate of the location

Returns: float
the x-coordinate of the location

get_y_coordinate(self)

 

Returns the y-coordinate of the location.

Returns: float
the y-coordinate of the location

get_distance(self, another_location)

 

Returns the distance between this location and another given location.

Parameters:
  • another_location () - some other location
Returns: float
the distance between the two locations

__str__(self)
(Informal representation operator)

 

Returns a description of the form (X, Y) of the location.

Returns: string
a string representation of the location
Overrides: object.__str__