Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions