#include "stdafx.h"
#include <string>
#include <iostream>
usingnamespace std;
int main()
{
int gas;
int batt;
bool on;
car cars;
int i;
string action;
string engine;
do
{
cout << "Welcome to the car class test" << endl << "Enter 'straight' to go forward, ";
cout << "'left' to turn left, and 'right; to turn right." << endl;
cout << "You can also check the battery and gas level by typing 'battery' and 'gas' respectivly." << endl;
cout << "type 'start' to start the car. You can also type 'park' to stop." << endl;
do
{
on = cars.geton();
batt = cars.batlvl();
gas = cars.gaslvl();
cin >> engine;
if(engine.compare('start') == 0)
{
cars.start();
cout << "The car has started" << endl;
}
else
cout << "The car is still in park. You must start the car first." << endl;
}
while(on == false);
while(batt || gas > 0)
{
cout << "What would you like to do?" << endl;
}
cin >> action;
for(i = 0;action[i] != '\0'; i++)
{
action[i] = tolower(action[i]);
}
if(action.compare('straight' || 'right' || 'left'))
{
cars.direction(action);
}
if(action.compare('battery'))
{
batt = cars.batlvl();
cout << "The battery level is " << batt << endl;
}
if(action.compare('gas'))
{
gas = cars.gaslvl();
cout << "The gas level is " << gas << endl;
}
}
batt = cars.batlvl();
gas = cars.gaslvl();
if(gas <= 0)
{
cout << "Your car ran out of gas." << endl;
}
elseif(batt <= 0)
{
cout << "Your battery died." << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
On all of my string.compare lines I am getting an error that says there are too many characters in constant. Can anyone tell me what this means? Thanks in advance. Oh and this whole thing is part of one large class, but I'm not getting errors from it.