Write a class named Taxicab that has three **private** data members: one that holds the current x-coordinate, one that holds the current y-coordinate, and one that holds the odometer reading (the actual odometer distance driven by the Taxicab, not the Euclidean distance from its starting point). The class should have an init method that takes two parameters and uses them to initialize the coordinates, and also initializes the odometer to zero. The class should have get methods for each data member: get_x_coord, get_y_coord, and get_odometer. The class does not need any set methods. It should have a method called move_x that takes a parameter that tells how far the Taxicab should shift left or right. It should have a method called move_y that takes a parameter that tells how far the Taxicab should shift up or down. For example, the Taxicab class might be used as follows:

Respuesta :

Answer:

See explaination

Explanation:

class Taxicab():

def __init__(self, x, y):

self.x_coordinate = x

self.y_coordinate = y

self.odometer = 0

def get_x_coord(self):

return self.x_coordinate

def get_y_coord(self):

return self.y_coordinate

def get_odometer(self):

return self.odometer

def move_x(self, distance):

self.x_coordinate += distance

# add the absolute distance to odometer

self.odometer += abs(distance)

def move_y(self, distance):

self.y_coordinate += distance

# add the absolute distance to odometer

self.odometer += abs(distance)

cab = Taxicab(5,-8)

cab.move_x(3)

cab.move_y(-4)

cab.move_x(-1)

print(cab.odometer) # will print 8 3+4+1 = 8

The program is an illustration of class and methods.

Classes in python provide all the standard features needed for the program, while the method is a function of an object.

#This defines the Taxicab class

class Taxicab():

   #This creates the init method

   def __init__(self, x, y):

       #The next two lines initialize the coordinates

       self.x_coordinate = x

       self.y_coordinate = y

       #This initializes the odometer readings to 0

       self.odometer = 0

   

   #This creates a get method for the x coordinate

   def get_x_coord(self):

       #This returns the x coordinate

       return self.x_coordinate

       

   #This creates a get method for the y coordinate

   def get_y_coord(self):

       #This returns the y coordinate

       return self.y_coordinate

   #This creates a get method for odometer readings

   def get_odometer(self):

       #This returns the odometer readings

       return self.odometer

   

   #This creates the move_x method

   def move_x(self, distance):

       self.x_coordinate += distance

       self.odometer += abs(distance)

       

   #This creates the move_y method

   def move_y(self, distance):

       self.y_coordinate += distance

       self.odometer += abs(distance)

At the end of the program, the class and the methods are well implemented.

Read more about similar programs at:

https://brainly.com/question/16087319