Question
PYTHON HELP SPEEDING FINE CALCULATOR: prompt: 1. with limit = 30, speed = 35, fine = 50 + (35- 30)*5 = $75 2. with limit
PYTHON HELP SPEEDING FINE CALCULATOR:
prompt:
1. with limit = 30, speed = 35, fine = 50 + (35- 30)*5 = $75 2. with limit = 50, speed = 110, fine = 50 + (110 50)*5 + 200 (penalty for speeding beyond 50mph over the limit) = $550 3. with limit = 65, speed = 58, fine = 0 SpeedingFineCalculator class :
a. Add 3 public static attributes: i. minimumFine: public static attribute represents the minimum amount of fine in dollars charged for speeding violation. Initialize it to 50. ii. penaltyPerMPH: public static attribute represents fine in dollars for each mph over the limit. Initialize it to 5. iii. penalty50BeyondLimit: public static attribute represents fine in dollars if clocked speed is 50 mph or more beyond the speeding limit. Initialize it to 200.
b. Add one private attribute: __speedLimit. This private attribute represents the speed limit in the given city limits.
c. Add one constructor that takes one OPTIONAL argument representing the speed limit and copies it to private attribute __speedLimit. Default value for the speedlimit argument is 25.
d. Add one public property called speedLimit. This is a public read-write property backed by __speedLimit . The getter for this property returns the private attribute __speedLimit. The setter for this property checks if the new value is negative, if so, it raises an exception with a message Speed limit cannot be negative. Otherwise it updates the __speedLimit attribute.
e. Add a method called calculateSpeedingFine that takes one argument representing the clocked speed and returns the speeding fine. It first checks if the argument is negative, if so raises an exception with a message Clocked speed cannot be negative. Otherwise calculates and returns the calculated fine as per the policy above using the three static attributes, the private instance attribute __speedLimit and the clocked speed.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started