GIVERIDE start_time, user, startLat, startLong, endLat, endLong, capacity
VIEWRIDE startLat, startLong, User
TAKERIDER User, rideid
Ride{
int id;
string driver;
pair<double,double>sLat,sL......
const int capacity;
int available;
string startTime;
Ride(start_time, user, startLat, startLong, endLat, endLong, capacity){
//initialize parameters
}
pair<double, double> getStart(){
//TODO
}
bool isAvailable(){
return available>=0;
}
void bookSeat{
available--;
}
};
SharingApp{
int id;
set<Ride*>avRides;
map<int,Ride*>LogRides;
bool checkDist(){
//logic <=5
}
double getDist(){
//logic
}
SharingApp(){
int id=0;
}
GiveRide(start_time, user, startLat, startLong, endLat, endLong, capacity){
id++;
Ride* newRide=new Ride(start_time, user, startLat, startLong, endLat, endLong, capacity);
LogRides[id]=newRide;
avRides.insert(newRide);
}
ViewRide(startLat, startLong, User){
for(auto nearbyRides: avRides){
auto RideStart=nearbyRide->getStart;
if(checkDist(RIdeStart,Startlat,StartLong)){
if(nearbyRide->isAvailable){
cout<<getDetails;
}
}
}
}
TakeRide(User, rideid){
Ride* targetRide=logRide[rideid];
if(targetRide->isAvailabe()){
cout<<"Booking Confirmed"<<endl;
targetRide->bookSeat();
if(!targetRide->isAvailable){
avRides.erase(targetRide);
}
}
else cout<<"Booking Failed"<<endl;
}
};