Question: in java Please implement the following classes: Police, Driver, and Car. The objective is to create a system where the police can detect the speed

in java
Please implement the following classes: Police, Driver, and Car. The objective is to create a system where the police can detect the speed of a driver on the highway. You must handle exceptions as described below:
If the speed exceeds 80 mph, throw an "OverSpeedException".
If the speed limit is below 50 mph, throw an "UnderSpeedException".
If the car is an ambulance, throw an "EmergencyException".
Within the main function, create instances of Driver, Car, and Police classes. Call the detectSpeed method of the Police instance, passing two parameters: the Driver and Car instances.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!