Design: Fine Calculation System
Design the core fine calculation logic, rule management, and API interfaces. Out of scope: payment processing, user authentication system.
Functional Requirements
Non-Functional Requirements
Jump into concepts and practice - no test required
+-------------+ +----------------+ +-------------+
| Client | <---> | API Server | <---> | Rule Engine |
+-------------+ +----------------+ +-------------+
| |
v v
+----------------+ +--------------+
| Database | | Audit Logger |
+----------------+ +--------------+What is the primary purpose of a fine calculation system in low-level design?
Which of the following is the correct way to represent a fine rate for a violation type in a configuration file?
violation_fine_rates = {'speeding': 100,'parking': 50,'signal_jump': 150}
Given the following code snippet, what will be the total fine calculated?
violation_fine_rates = {'speeding': 100, 'parking': 50}violations = ['speeding', 'parking', 'speeding']total_fine = sum(violation_fine_rates[v] for v in violations)print(total_fine)
Identify the error in the following fine calculation code snippet:
violation_fine_rates = {'speeding': 100, 'parking': 50}violations = ['speeding', 'parking', 'signal_jump']total_fine = sum(violation_fine_rates[v] for v in violations)print(total_fine)
You are designing a fine calculation system that must support multiple violation types, each with different fine rates and possible discounts for repeat offenses. Which design approach is best?