مرحبا
هذا لاالسؤال
implement a pointer based linked list of integers or characters with the necessary opreations, such as insert, delete, and print.
once you get it working, incorporate the implementation of CAR ADT written for the assigment in chapter one to allow the user to create a list of commands that can be executed all at once.for example, the user may insert the list of commands to drive, fill tank, service, then drive again.the user should be given an option to execute the commandes.
possible options can be as folliws:
1.insert a command.
2.delete a command.
3.print all command.
4.execute the list.
5. exite.
السؤال الي يقصدونه فيه هذا اجابته مسويته قبل
#include <iostream.h>
class Car {
private:
float water;
float fuel;
float oil;
int engine;
public:
Car() {
water=0.0; fuel=0.0;
oil=0.0; engine=0;
}
void set_water(float w)
{
water=w;
}
void set_fuel(float f)
{
fuel=f;
}
void set_oil(float o)
{
oil=o;
}
void set_engine(int e)
{
engine=e;
}
float getwater()
{return water;}
float getoil()
{return oil;}
int getengine()
{ return engine;}
float getfuel()
{ return fuel;}
void start()
{
engine = 1;
cout << "Engine is On\n";
}
void drive()
{
if( engine == 0 )
{
cout << "can't drive when engine is off\n";
return;
}
float distance;
float w1,f1,o1;
cout<<"distance = ";
cin>>distance;
w1=distance*1;
o1=distance*1;
f1=distance*1;
cout << "Drove " << distance << " kilometers \n";
if( f1 > fuel )
cout << "go to petrol station\n";
if( o1 > oil )
cout << "there's no oil\n";
if( w1 > water )
cout << "there's no water \n";
oil = oil - o1;
water = water - w1;
fuel = fuel - f1;
}
void filltank()
{
set_fuel(100);
cout << "Fuel is now full\n";
}
void service()
{
set_oil(100);
set_water(100);
cout << "Oil now ok\n";
cout << "Water now ok\n";
}
void stope()
{
engine=0;
cout<<"good bye\n";
}
};
void main()
{
Car car1;
int choose = 0;
do
{
cout<<"please choose one of these:\n 1 to start\n 2 to drive\n 3 to stop\n 4 to fill tank\n 5 to service\n 6 to exit\n";
cin>>choose;
switch(choose)
{
case 1:
car1.start(); break;
case 2:
car1.drive(); break;
case 3:
car1.stope(); break;
case 4:
car1.filltank(); break;
case 5:
car1.service(); break;
case 6:
cout<<"thanks\n"; break;
default:
cout<<"errore\n";
}
} while( choose != 6 );
}
والي ابي اعرف شلون يستوي وافهمه قبل وشنو قصدهم
هذا>>> to allow the user to create a list of commands that can be executed all at once؟؟
وشكرا
بأسرع وقت عشان اخذ راحتي وانه احله من فضلكم