# Import necessary libraries
import datetime
# Define a class for emergency incidents
class Emergency:
def __init__(self, incident_type, location, timestamp):
self.incident_type = incident_type
self.location = location
self.timestamp = timestamp
# Define a class for the emergency response app
class EmergencyResponseApp:
def __init__(self):
self.incidents = []
# Method to report an emergency incident
def report_incident(self, incident_type, location):
timestamp = datetime.datetime.now()
incident = Emergency(incident_type, location, timestamp)
self.incidents.append(incident)
print(“Incident reported successfully.”)
# Method to display all reported incidents
def display_incidents(self):
for idx, incident in enumerate(self.incidents, 1):
print(f”Incident {idx}:”)
print(f”Incident Type: {incident.incident_type}”)
print(f”Location: {incident.location}”)
print(f”Timestamp: {incident.timestamp}”)
print()
# Sample usage of the emergency response app
if __name__ == “__main__”:
app = EmergencyResponseApp()
app.report_incident(“Fire”, “123 Main St”)
app.report_incident(“Medical Emergency”, “456 Elm St”)
app.display_incidents()
Leave a comment