Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started