void read_time(int*hour, int* min, string s);
string get_licenseNo();
void print();
};
class car : public carParking
{
public:
int time_Inhour,time_Inmin,time_Outhour, time_Outmin, time,fare;
int get_time(int, int, int, int);
int get_amount(int);
void details(int , int , int, int, int , int );
};
}
int car::get_time(int time_Inhour, int time_Inmin, int time_Outhour, int time_Outmin)
{
//Check the input 55 for the hour
// and 55 for the minutes
if (time_Outhour == 55 && time_Outmin == 55)
return -2;
//Check the input time of 99 for the hour
//and 99 for the minutes
if (time_Inhour == 99)
return -1;
if (time_Inhour <= time_Outhour)
return (time_Outhour - time_Inhour) * 60 + time_Outmin - time_Inmin;
return (time_Outhour + 24 - time_Inhour) * 60 + time_Outmin - time_Inmin;
}
int car::get_amount(int time)
{
//Check the drive has a special parking pass
if (time == -1)
return 5;
// Check the drive has lost their ticket
if (time == -2)
return 110;
// Less than 30 minutes
if (time <= 30)
return 3;
// Between 30 Minutes – 1 Hour
if (time <= 60)
return 5;
//Between 1 Hour – 2 Hours
if (time <= 120)
return 10;
//Between 2 Hours – 3 Hours
if (time <= 180)
return 15;
//Between 3 Hours – 4 Hours
if (time <= 240)
return 17;
//Each half hour over four hours
if (time <= 720)
return 20;
//error
return -1;
}
void car::details(int time_Inhour, int time_Inmin, int time_Outhour, int time_Outmin, int time, int Fare)
{
//Check the drive has a special parking pass
if (time_Inhour == 99)
cout << "The person has a special parking pass.Fare is $" << Fare << endl;
// Check the drive has lost their ticket
else if (time_Outhour == 55)
cout << "In-time: " << time_Inhour << ":" << time_Inmin << endl
<< "The drive has lost their ticket\nFare is: $" << Fare << endl;
else
cout << "In-time: " << time_Inhour << ":" << time_Inmin << endl << "Out-time:" << time_Outhour << ":" << time_Outmin << endl << "Total-time: " << time << "mins" << endl << "Fare is $" << Fare << endl;
}
main
// Project Parking payment Machine
// Project group Karanpreet Singh and Amitpal Singh
int main()
{
carparked car1;
carParking car2;
car car3;
cout << " ******************* Welcome to Royal Center Parking****************** \n";
cout << "Choose the following options\n ";
cout << "Enter 1 if you want to park a Car";
cout << "Enetr 2 if you want to leave";
cout << "Enter 3 to exit the system\n";
int x;
cin >> x;
if (x == 1)
{
cout << "Enter the Details the system ask you:\n";
car1.get_carMake();
car1.get_carColor();
car1.get_carModel();
car2.get_licenseNo();
cout << "Thank you!! Your car has been parked!! ";
}
else if (x == 2)
{
int time_Inhour, time_Inmin, time_Outhour, time_Outmin, time, price;
cout << "Please Follow the instructions\n";
car2.read_time(&time_Inhour, &time_Inmin, "in-time");
car2.read_time(&time_Outhour, &time_Outmin, "out-time");
time = car3.get_time(time_Inhour, time_Inmin, time_Outhour, time_Outmin);
price = car3.get_amount(time);
car3.details(time_Inhour, time_Inmin, time_Outhour, time_Outmin, time, price);
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.
Please post the actual error message and what IDE or compiler you are using.
The ".cpp" file that goes with the header file is OK exept line 7 which is redundant do to that line being in the header file.
The actual problem comes from the "main" file what would be about line 4 #include "Source.cpp" . This includes the code from this file twice when you compile the program. It is a very rare occasion when you include a ".cpp" like this and not something you are ready for at this time. Otherwise you should never include a ".cpp" file in another ".cpp" file. After removing this line from main the program compiled with no linker errors.
I have not tested a run yet to see what happens, but it is a step in the right direction.