Public class computer
{
Private int I = 1;
Public void run () throws LanPingExpion, MaoYanExcetion
{
If (I = 2)
Throw new LanPingExpion ("blue screen ");
If (I = 3 ){
Throw new MaoYanExcetion ("smoke ");
}
System. out. println ("computer running ");
}
Public void reset ()
{
I = 1;
System. out. println ("computer restart ");
}
Public class MaoYanExcetion extends Exception
{
Public MaoYanExcetion (String message ){
Super (message );
}
}
Public class LanPingExpion extends Exception
{
Public LanPingExpion (String message)
{
Super (message );
}
Public class NoPanException extends Exception
{
Public NoPanException (String message)
{
Super (message );
}
Public class Teacher {
Private String name;
Private computer cpu;
Teacher (String name)
{
This. name = name;
Cpu = new computer ();
}
Public void prelece () throws MaoYanExcetion, NoPanException
{
Try
{
Cpu. run ();
} Catch (LanPingExpion e)
{
Cpu. reset ();
} Catch (MaoYanExcetion e ){
Test ();
Throw new NoPanException ("class cannot continue" + e. getMessage ());
}
System. out. println ("class ");
}
Public void test (){
System. out. println ("exercise ");
}
}
Public class ExceTepionTest
{
Public static void main (String [] args)
{
Teacher t = new Teacher ("instructor bi ");
Try {
T. prelece ();
} Catch (Exception e ){
System. out. println ("holiday" + e. toString ());
}
}
}