Need Help Following Problem Java Modify Code Written Far Following Three Things Write Met Q43887092
Need some help on the following problem in java. I have tomodify the code I written so far(below) to do the following threethings:
a). Write a method called diagnostics that occasionally throwsany one of the exceptions you have created depending on the valuesgenerated by a random-number generator.
b). Write a method called display that calls diagnostics andprovides exception handlers to display a message when an exceptionoccurs. Otherwise, if an exception does not occur, method displayshould print out “Diagnostic test completed–no problem found.”
c). Suppose that the display method contains three catch clauseswith parameter types: FootBrakeException, BrakeException, andException. Explain which orders of the catch blocks would preventthe execution of an exception handler.
//code
public class AutoExceptions {
class NoStartException extends Exception {
public NoStartException() {
this(“No StartException”);
}
public NoStartException(Stringmessage) {
super(message);
}
classBadIgnitionException extends NoStartException{
public BadIgnitionException() {
this(“Bad IgnitionException”);
}
public BadIgnitionException(String message){
super(message);
}}
classDeadBatteryException extends NoStartException{
public DeadBatteryException() {
this(“Dead BatteryException”);
}
public DeadBatteryException(String message){
super(message);
}
}
}
class LightsException extends Exception {
public LightsException() {
this(“LightsException”);
}
public LightsException(Stringmessage) {
super(message);
}
classHeadLightException extends LightsException{
public HeadLightException() {
this(“Head LightException”);
}
public HeadLightException(String message){
super(message);
}}
classBrakeLightException extends LightsException{
public BrakeLightException() {
this(“Brake LightException”);
}
public BrakeLightException(String message){
super(message);
}
}
classTailLightException extends LightsException{
public TailLightException() {
this(“Tail LightException”);
}
public TailLightException(String message){
super(message);
}
}
}
class BrakeException extends Exception {
public BrakeException() {
this(“BrakeException”);
}
public BrakeException(Stringmessage) {
super(message);
}
classFootBrakeException extends BrakeException{
public FootBrakeException() {
this(“Foot BrakeException”);
}
public FootBrakeException(String message){
super(message);
}}
classParkingBrakeException extends BrakeException{
public ParkingBrakeException() {
this(“Parking BrakeException”);
}
public ParkingBrakeException(String message){
super(message);
}
}
}
}
Expert Answer
Answer to Need some help on the following problem in java. I have to modify the code I written so far(below) to do the following t…
OR