Help

I am having trouble even understanding what I am supposed to be doing. Most the time I just copy code in class and then rework it but we weren't given that for this project. This is the question-

Intermediate C++ Project
Background: Suppose that you are managing a company with 4 tow trucks owned by four different drivers(You pick up the names).

1.Each tow truck has its “home” where the driver will return after each service. The service range that your company covers is a 10 miles by 10 miles area, which can be modeled as a square in the coordinate system as illustrated in the following graph. (no graph sorry) The coordinates of the “home” of the 4 tow trucks are (4, 3.5), (3.5, 7), (7.5, 4), and (7.2,7.2) respectively.

2.When an operator get a call for requesting a towing service, he/she will ask for the location(X/Y coordinate information)where towing services are needed.a.If the address is out of the 10X10 mile coverage, the request is ignored. Otherwise the program will pick the tow truck whose “home” is closest to this accident location. b.The driver of the selected tow truck will get a payment proportional to the one-way distance that he needs to drive, with the rate being $12/mile.

3.The service requests processing will continue till the operator quit the program. Print out the total revenue of each tow truck driver(show their names)right before the operator quits the program.

Guidelines
1.Define the class first based on in-class discussions or use your own design that is justified .
2.Implement the class and the .Mainfile.
3.Use functions for object array processing in the main function

I have done the class declarations and commented the first .h file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 /*
*	TowTruck.h
*	Definition for the TowTruck class
*	Author:		XXX
*	Created on:	
*/
#ifndef TOWTRUCK_H
#define TOWTRUCK_H
class TowTruck
{
	//Data members
	private:
		double homeX;		//X coordinate of towtruck's home
		double homeY;		//Y coordinate of towtruck's home
		std::string driverName;
		double income;
	//Member functions
	public:
		//setters and getters
		//constructor
		
		/*	
		*	calculateDistance
		*	Function to calculate the distance between the accident location
		*		and the home of this towtruck
		*	@param 1:	X coordinate of accident location
		*	@param 2:	Y coordinate of accident location
		*	@return:	the distance between the accident location and towtruck home
		*/
		double calculateDistance(double, double);

		/**
		*	updateIncome
		*	Update the income of the driver by adding payment for each service
		*	@param:		distance
		*	@return:	none. The data member income will be updated
		*/
		void updateIncome(double);

		/**
		*	printInfor
		*	Print basic information about the tow truck
		*	@parameter:		none
		*	@return:		none
		*/
		void printInfor();

};
#endif 

He gave us comments for the main file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
*	Service.cpp
*	Main procedure for managing towtruck service.
*	Author:		
*	Created on:		
*/

int main()
{
	//Create profiles for the tow trucks

	//Design a while loop to make sure the operator
	//	can process as many service requests as allowed

		//Ask for accident location
			//If not within the range, skip it

		//Decide the tow truck closet to accident to serve this request

		//Add CERTAIN amount of payment to the RIGHT driver

	//Before exiting the program, generate an income report for every tow truck
}






Most the time I just copy code in class and then rework it
Unfortunately that was a mistake. You have to learn to write code from the start.

Fortunately your class definition looks good. Write the methods for the class. Then put some temporary code at the beginning of main() to test out your methods. Create a TowTruck, get the distance to a point or two. Add some income.

Next, you must decide how you're going to store the 4 TowTrucks. Also I suggest a function to find the closest TowTruck to a given point.

Then you can fill in the main program based on the comments that your prof provided.
Topic archived. No new replies allowed.