49.4k views
3 votes
Assume you have class AutoFactory with two static methods called shutdown and reset. Neither method has any parameters. The shutdown; method may throw a ProductionInProgressException. Write some code that invokes the shutdown method. If a ProductionInProgressException is thrown, your code should then invoke the reset method.

User Canecse
by
5.6k points

1 Answer

2 votes

// Writing C++ code

static shutdown(){

try{

// Code that we need to check if it throws exception, which is not discussed //in question

}catch(e){

// e will have a value if the exception is thrown

if(e == ProductionInProgressException)

this.reset();

}

User Wickkiey
by
5.6k points