Implement a structure of car having car model, plate number, location, isParked (boolean type).
Car can move and park.
Move(): This function may update the location of car as it is moved.
Park(): This function added car details in the system and update is parked status.
Your program will also tell the parking managemt about the status of parking using isParked().
IsParked() : This function can find a car is it parked on not?
#include<iostream>
#include <string>
using namespace std;
class Car{
private:
string model;
string plateNumber;
string location;
bool is_Parked;
public:
Car(){
is_Parked=false;
}
//Move(): This function may update the location of car as it is moved.
void Move(){
cout<<"Enter a new location: ";
getline(cin,location);
is_Parked=false;
}
//Park(): This function added car details in the system and update is parked status.
void Park(){
cout<<"Enter model: ";
getline(cin,model);
cout<<"Enter plate number: ";
getline(cin,plateNumber);
cout<<"Enter location: ";
getline(cin,location);
is_Parked=true;
}
bool isParked(){
return is_Parked;
}
};
int main()
{
Car c;
c.Park();
if(c.isParked()){
cout<<"Is parked\n\n";
}else{
cout<<"Is not parked\n\n";
}
c.Move();
if(c.isParked()){
cout<<"Is parked\n\n";
}else{
cout<<"Is not parked\n\n";
}
system("pause");
return 0;
}
Comments
Leave a comment