Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Directions:Please complete the following assignment to signify your completion o

ID: 665260 • Letter: D

Question

Directions:Please complete the following assignment to signify your completion of Unit 11. All programming projects need to be completed and submitted electronically, following the Electronic Submission Guidelines discussed in class. Please cherry-pick from your solution folder and submit just the .cpp files you created as well as .exe file that Visual Studio built from your code.Background:Designing and creating classes is a fundamental ability every C++ programmer needs to develop. With this assignment, you will create classes from scratch. When working with C++, you need to be very detail-oriented. The structure of the .h and .cpp files are very important and small differences that you inadvertently type can lead to countless errors. In a past section, a student reported 12 errors from just a single character being wrong. So expect many errors. Or better yet, be very careful as you write C++ The goal of this project is to realize that member variables can be used to remember things. As client driver code calls the methods of the class, the object can remember what was recently done to it by setting private member variables. Another goal of this project to realize that not all methods are created equal. Sometimes, there is an order to the way the operations of a class must be called. Depending on the sequence of steps taken, the object may behave differently. In all the homework from here on out, the top part of the class box (the public methods) are what is being scored. You can implement them however you like, as long as they achieve what I am looking for. 99.5% of you will likely follow the bottom part of the box (the private members) which is my suggestion for how to get it done.Project 1: JoggerThe class Jogger represents a regular exercising person. Implement the class Jogger so that each instance of Jogger has a string name and three int values which mark how far this instance has walked, run and jogged.Following the class diagrams shown below, implement the Jogger class. Embed your class in a suitable test program that provides the sample dialogue shown below. You may choose to create any number of additional methods, but you are required to implement all of the public methods shown below. You are free to ignore the private parts of the class I suggest below.
Implementation DetailsSample Driver
JoggerJogger( string name );

void walk( int amount );
void run( int amount );
void jog( int amount );void displayStats( );
void clearStats( );string name;
int walkedSoFar;
int ranSoFar;
int joggedSoFar;
Jogger marathoner( "Sonia O’Sullivan" );
marathoner.run( 500 );
marathoner.displayStats( );
marathoner.run( 500 );
marathoner.displayStats( );
marathoner.clearStats( );
marathoner.run( 500 );
marathoner.displayStats( );Jogger liteWeight( "You" );
liteWeight.walk( 10 );
liteWeight.jog( 10 );
liteWeight.displayStats( );Sample OutputSonia O’Sullivan walked 0 miles, ran 500 miles and jogged 0 milesSonia O’Sullivan walked 0 miles, ran 1000 miles and jogged 0 milesSonia O’Sullivan walked 0 miles, ran 500 miles and jogged 0 milesYou walked 10 miles, ran 0 miles and jogged 10 miles

Explanation / Answer

#include<iostream>
#include<string.h>

using namespace std;

class Jogger
{
private:
string name;
int walkedSoFar;
int ranSoFar;
int joggedSoFar;
public:
Jogger(string n);
void walk( int amount );
void run( int amount );
void jog( int amount );
void displayStats( );
void clearStats( );
};

Jogger::Jogger(string n) //Constructor for initialising the object
{
name = n; // assigning the provided name by the user to the variable name
walkedSoFar=0;
ranSoFar=0;
joggedSoFar=0;
}
void Jogger::walk(int amount)
{
walkedSoFar = walkedSoFar+amount;   //Adding the additional miles the person has walked
}

void Jogger::run(int amount)
{
ranSoFar = ranSoFar+amount;   //Adding the additional miles the person has ran
}

void Jogger::jog(int amount)
{
joggedSoFar = joggedSoFar+amount;   //Adding the additional miles the person has jogged  
}

void Jogger::displayStats( ) //Displaying the details of the person
{
cout<<name<<" walked "<<walkedSoFar<<" miles, ran "<<ranSoFar<<" miles and jogged "<<joggedSoFar<<" miles ";  
}

void Jogger::clearStats( ) //Clears all the miles the person for which he walked,ran,jogged and set them to zero
{
walkedSoFar=0;
ranSoFar=0;
joggedSoFar=0;   
}


int main()
{
Jogger marathoner( "Sonia O’Sullivan" );
marathoner.run( 500 );
marathoner.displayStats( );
marathoner.run( 500 );
marathoner.displayStats( );
marathoner.clearStats( );
marathoner.run( 500 );
marathoner.displayStats( );

Jogger liteWeight("You");
liteWeight.walk( 10 );
liteWeight.jog( 10 );
liteWeight.displayStats( );
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote