Skip to content

Commit

Permalink
Merge pull request #226 from Pranjal360Agarwal/testing
Browse files Browse the repository at this point in the history
Realtime bus tracking feature added
  • Loading branch information
Pranjal360Agarwal committed Oct 21, 2023
2 parents 0e5d2a4 + 304e803 commit 5d838ca
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions New Features/realtime.py
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)

1 comment on commit 5d838ca

@vercel
Copy link

@vercel vercel bot commented on 5d838ca Oct 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.