-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from Pranjal360Agarwal/testing
Realtime bus tracking feature added
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import random | ||
import time | ||
|
||
class Bus: | ||
def __init__(self, bus_id, route, total_seats): | ||
self.bus_id = bus_id | ||
self.route = route | ||
self.total_seats = total_seats | ||
self.current_location = 0 | ||
|
||
def move_bus(self): | ||
# Simulate bus movement along the route | ||
if self.current_location < len(self.route) - 1: | ||
self.current_location += 1 | ||
|
||
def get_location(self): | ||
return self.route[self.current_location] | ||
|
||
def track_bus(bus, interval=5): | ||
while True: | ||
bus.move_bus() | ||
current_location = bus.get_location() | ||
print(f"Bus {bus.bus_id} is currently at {current_location}") | ||
time.sleep(interval) | ||
|
||
# Example usage: | ||
bus_route = ["City A", "City B", "City C", "City D"] | ||
bus1 = Bus(bus_id=1, route=bus_route, total_seats=30) | ||
|
||
# Start tracking the bus in real-time | ||
track_bus(bus1) |
5d838ca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
apna-bharat-bus-booking-reservation-system – ./
apna-bharat-bus-booking-reservation-system-pranjal360agarwal.vercel.app
apna-bharat-bus-booking-reservation-system.vercel.app
apna-bharat-bus-booking-reservatio-git-e01564-pranjal360agarwal.vercel.app