whats wrong with this progam
Code:
#include<iostream.h>
class carADT{
private:
static int fuel,water,oil;
public:
carADT();
carADT(int ff=1000,int ww=1000,int oo=1000);
int swOn();
int drive();
int stop();
int setspeed();
void service();
void fillTank();
};
carADT::carADT(){
fuel=water=oil=0;
}
carADT::carADT(int ff,int ww,int oo){
fuel=ff;
water=ww;
oil=oo;
}
carADT::int swOn(){
cout<<"you can drive now:\n";
return 1;
}
carADT::int drive(){
carADT d;
int x,z;
x=d.swOn();
d.setspeed();
if(x==1){
while((z=d.stop)!=0){
for(int c=1000;c>0;c--){
fuel--;
water--;
oil--;
}}}
if(fuel==water==oil==0)
return 1;
else
return 0;
}
carADT::int stop(){
carADT s;
int z;
w=s.speed();
z=s.drive();
if(z==1||w==0)
return 0;
else{
s.switchOn(0);
return 1;
}
carADT::int setspeed(){
int sp,spd=0;
cout<<"what is the speed you want:\n"<<endl;
cin>>sp;
while(spd!=sp){
spd++;
cout<<"the speed is "<<spd<<endl;
}
if(sp==spd==0)
return 0;
}
carADT::void service(){
fuel=oil=water=1000;
}
carADT::void fillTank(){
if(fuel!=2000){
fuel=2000;
}
int main(){
int y,r;
char s,f;
cout<<"Do you want to drive:\n";
cin>>y;
if(y==1){
cout<<"do you want to stop: enter y/n\n";
cin>>s;
if(s=='y')
D.stop();
else{
while(!(D.stop()){
r=D.drive();
cout<<"do you want to stop\n";
cin>>s;
if(s=='y')
D.stop(); }}
if(r==1)
D.service();
}
cout<<"do you want to fill the tank:\n";
cin>>f;
if(f=='y')
D.fillTank();
return 0;
}
Please use [code][/code]Tags