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

Class Location

source code

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.
source code
 
get_x_coordinate(self)
Returns the x-coordinate of the location
source code
 
get_y_coordinate(self)
Returns the y-coordinate of the location.
source code
 
get_distance(self, another_location)
Returns the distance between this location and another given location.
source code
 
__str__(self)
Returns a description of the form (X, Y) of the location.
source code

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)

source code 

Initializes a new location with the given coordinates.

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

get_x_coordinate(self)

source code 

Returns the x-coordinate of the location

Returns:
the x-coordinate of the location

get_y_coordinate(self)

source code 

Returns the y-coordinate of the location.

Returns:
the y-coordinate of the location

get_distance(self, another_location)

source code 

Returns the distance between this location and another given location.

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

__str__(self)
(Informal representation operator)

source code 

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

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