class LanPinException extends Exception
{
LanPinException(String message)
{
super(message);
}
}
class MaoYanException extends Exception
{
MaoYanException(String message)
{
super(message);
}
}
class NoPlanException extends Exception
{
NoPlanException(String msg)
{
super(massage);
}
}
class Computer
{ private int state=3;
public void run()throws LanPinExceptin,MaoYanException
{
if(state=2)
throw new LanPinException("电脑蓝屏");
if(state=3)
throw new MaoYanException("电脑冒烟");
System.out.println("电脑运行");
}
public void reset()
{
state=1;
System.out.println("电脑重启");
}
}
class Teacher
{
private String name;
private Computer cop;
Teacher(String name)
{
this.name=name;
cop=new Computer();
public void jiangke()throws NoPlanException
{
try
{
cop.run();
}
catch (LanPinException e)
{
cop.reset();
}
catch (MaoYanException e)
test();
{
throw new NoPlanException("课时无法继续"+e.getMassage());
}
System.out.println("讲课");
|
|