Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Written in c++ please All of your functions, including constructors, should take their parameters in the same order in which they are listed in the

  • Written in c++ please
  • All of your functions, including constructors, should take their parameters in the same order in which they are listed in the specifications.
  • Constructors should not ask for input from the user - they should just initialize the class data members using the values that were passed as parameters and/or default values.
  • Remember to not include a main method in the files you submit.
  • Do not put "using" statements in header (.hpp) files. Instead put "std::" in front of the names you use, e.g. "std::cout".
  • Remember to have function comment blocks (in your .cpp files) as stipulated in the Code Style Guidelines.

Write a class called Taxicab that has three int fields (data members) to store its current x- and y-coordinates and the total distance it has driven so far (the actual distance driven by the Taxicab, not the Euclidean distance from it's starting point). The class should have a constructor that takes two parameters and uses them to initialize the coordinates, and also initializes the distance traveled to zero. The class should have a default constructor that sets all three fields to zero. The class should have a get method for each data member. It should have a method called moveX that takes an int parameter that tells how far the Taxicab should shift left or right. It should have a method called moveY that takes an int parameter that tells how far the Taxicab should shift up or down. For example, the Taxicab class might be used as follows:

Taxicab cab1; Taxicab cab2(5, -8); cab1.moveX(3); cab1.moveY(-4); cab1.moveX(-1); cout << cab1.getDistanceTraveled() << endl; cab2.moveY(7); cout << cab2.getYCoord() << endl;

Your functions should have the following names:

  • getXCoord
  • getYCoord
  • getDistanceTraveled
  • moveX
  • moveY

The files must be named: Taxicab.hpp and Taxicab.cpp

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

More Books

Students also viewed these Databases questions

Question

Why did Ron decide not to undergo genital reconstruction surgery?

Answered: 1 week ago

Question

dy dx Find the derivative of the function y=(4x+3)5(2x+1)2.

Answered: 1 week ago

Question

Draw and explain the operation of LVDT for pressure measurement

Answered: 1 week ago

Question

7. Identify six intercultural communication dialectics.

Answered: 1 week ago