answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nalin
2 months ago
9

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:
Computers and Technology
1 answer:
amid [951]2 months ago
7 0

Response:

Refer to the explanation

Details:

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

# increase the odometer with the absolute distance

self.odometer += abs(distance)

def move_y(self, distance):

self.y_coordinate += distance

# increase odometer with the absolute distance

self.odometer += abs(distance)

cab = Taxicab(5,-8)

cab.move_x(3)

cab.move_y(-4)

cab.move_x(-1)

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

You might be interested in
During which stage does the central processing unit analyze the instruction and encode it in the form of a number, and then gene
amid [951]
a. fetch. During the fetch cycle, the device retrieves a command from memory.
4 0
1 month ago
Susan is assisting a web designer to create a promotional web page on eco-friendly classroom designs. She uses color combination
ivann1987 [1066]
Going with the Complementary Color Chord

Between the choices of Complementary and Split-Complementary schemes, I prefer the complementary approach due to its high contrast and lively energy, resulting in a bold appearance. This color pairing is especially effective when aiming for visuals that really grab attention.

6 0
3 months ago
A business wants to centralize its administrative tasks. At the same time, it wants the existing systems to manage and sustain t
Harlamova29_29 [1022]
Time management and documentation.
7 0
1 month ago
Read 2 more answers
Other questions:
  • Which of these is an example of the integrity principle that can ensure your data is accurate and untampered with?
    10·2 answers
  • The part of the computer that contains the brain, or central processing unit, is also known as the A.monitor B.modem C.keyboard
    10·1 answer
  • SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick R
    9·1 answer
  • Modern operating systems decouple a process address space from the machine’s physical memory. List two advantages of this design
    15·1 answer
  • Consider the following skeletal C program: void fun1(void); /* prototype */ void fun2(void); /* prototype */ void fun3(void); /*
    11·1 answer
  • Team A found 342 errors during the software engineering process prior to release. Team B found 184 errors. What additional measu
    12·1 answer
  • Using the format method, fill in the gaps in the convert_distance function so that it returns the phrase "X miles equals Y km",
    12·1 answer
  • The act of infiltrating a remote computer system is called​
    14·1 answer
  • Write a MATLAB function named average_of_scores_with_drops The function will have two inputs and two return values. The first in
    11·1 answer
  • assume that name is a variable of type stirng that has been assigned a value write an expression whose value is the last charact
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!