class Demo1
{
public static void main(String[] args)
{
Teacher t=new Teacher();
try
{
t.teach();
}
catch(ChangeZYException e)
{
System.out.println(e.getMessage());
System.out.println("我要疯了");
}
}
}
class Teacher
{
Computer c=new Computer();
void teach()
{
try
{
c.run();
}
catch (LanPingException e)
{
System.out.println(e.getMessage());
c.reset();
this.teach();
}
catch (MaoYanException e)
{
System.out.println(e.getMessage());
System.out.println(" 学生自习");
throw new ChangeZYException(e.getMessage()+" 看着处理吧...");
}
}
}
class ZGC
{
void xl(Computer c)
{
c.state=0;
System.out.println("电脑进行了维修");
}
}
class Computer
{
int state=0;
void run() throws LanPingException,MaoYanException
{
if (state==0)
{
System.out.println("电脑运行");
}
else if (state==1)
{
throw new LanPingException("电脑蓝屏");
}
else if(state==2)
{
throw new MaoYanException("冒烟");
}
}
void reset()
{
System.out.println("电脑重新启动");
state =0;
}
}
class LanPingException extends Exception
{
public LanPingException(String message)
{
super(message);
}
}
class MaoYanException extends Exception
{
public MaoYanException(String message)
{
super(message);
}
}
class ChangeZYException extends Exception
{
public ChangeZYException(String message)
{
super(message);
}
}
[img=487,106]file:///C:/Users/lenovo/AppData/Roaming/Tencent/Users/793648972/QQ/WinTemp/RichOle/ZS(3NMKGAB%7DG[S1LUJ6W]AY.jpg[/img]
|