-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcfafacfa
67 lines (54 loc) · 3.03 KB
/
cfafacfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Import necessary libraries
from datetime import datetime
from typing import List, Optional
# Data classes for Crimefinderapp
class PettyCrime:
def __init__(self, crime_type: str, description: str, date_reported: datetime, location: str):
self.crime_type = crime_type # Type of petty crime (e.g., lost keys, misplaced phone)
self.description = description # Detailed description of the incident
self.date_reported = date_reported # Date when the crime was reported
self.location = location # Location where the incident occurred
class NaturalCrime:
def __init__(self, crime_type: str, cause: str, severity: str, date_reported: datetime, location: str):
self.crime_type = crime_type # Type of natural crime (e.g., flooding, landslide)
self.cause = cause # Cause of the natural incident
self.severity = severity # Severity of the incident (e.g., minor, moderate, severe)
self.date_reported = date_reported # Date when the crime was reported
self.location = location # Location where the incident occurred
# Library to manage petty crimes
class CrimeLibrary:
def __init__(self):
self.petty_crimes: List[PettyCrime] = []
def report_petty_crime(self, crime: PettyCrime):
self.petty_crimes.append(crime)
def find_petty_crime(self, location: Optional[str] = None) -> List[PettyCrime]:
if location:
return [crime for crime in self.petty_crimes if crime.location == location]
return self.petty_crimes
# Library to manage natural crimes
class NaturalCrimeLibrary:
def __init__(self):
self.natural_crimes: List[NaturalCrime] = []
def report_natural_crime(self, crime: NaturalCrime):
self.natural_crimes.append(crime)
def find_natural_crime(self, severity: Optional[str] = None) -> List[NaturalCrime]:
if severity:
return [crime for crime in self.natural_crimes if crime.severity == severity]
return self.natural_crimes
# Sample Usage
if __name__ == "__main__":
# Initialize libraries
petty_crime_library = CrimeLibrary()
natural_crime_library = NaturalCrimeLibrary()
# Report some petty crimes
petty_crime_library.report_petty_crime(PettyCrime("Lost Keys", "Left keys at the café.", datetime.now(), "Café A"))
petty_crime_library.report_petty_crime(PettyCrime("Misplaced Phone", "Forgot phone at the gym.", datetime.now(), "Gym B"))
# Report a natural crime
natural_crime_library.report_natural_crime(NaturalCrime("Flood", "Heavy rain", "Severe", datetime.now(), "Area C"))
# Retrieve and print reported crimes
print("Reported Petty Crimes:")
for crime in petty_crime_library.find_petty_crime():
print(f"{crime.date_reported}: {crime.crime_type} - {crime.description} at {crime.location}")
print("\nReported Natural Crimes:")
for crime in natural_crime_library.find_natural_crime():
print(f"{crime.date_reported}: {crime.crime_type} - {crime.cause} at {crime.location} (Severity: {crime.severity})")