classLanPingExceptionextendsException{LanPingException(Stringmessage){super(message);}}classMaoYanExceptionextendsException{MaoYanException(Stringmessage){super(message);...
class LanPingException extends Exception
{
LanPingException(String message)
{
super(message);
}
}
class MaoYanException extends Exception
{
MaoYanException(String message)
{
super(message);
}
}
class NoPlanException extends Exception
{
NoPlanException(String message)
{
super(message);
}
}
class DaoRu extends Scanner
{
private int state;
DaoRu(int state)
{
this.state=nextInt;
}
public int getState()
{
return state;
}
}
class Computer
{
Scanner S1=new Scanner(System.in);
state=S1.getState();
public void run() throws LanPingException,MaoYanException
{
if(state==2)
throw new LanPingException("因为蓝屏了");
if(state==3)
throw new MaoYanException("因为冒烟了");
System.out.println("运行");
}
public void reset()
{
state=1;
System.out.println("重启");
}
}
class Teacher
{
private String name;
private Computer cmpt;
Teacher(String name)
{
this.name=name;
cmpt=new Computer();
}
public void prelect()throws NoPlanException
{
try
{
cmpt.run();
}
catch (LanPingException e)
{
cmpt.reset();
}
catch (MaoYanException e)
{
test();
throw new NoPlanException("课时无法继续"+e.getMessage());
}
System.out.println(name+"在讲课");
}
public void test()
{
System.out.println("练习");
}
}
class ExceptionTest
{
public static void main(String[] args)
{
Teacher t=new Teacher("毕老师");
try
{
t.prelect();
}
catch (NoPlanException e)
{
System.out.println(e.toString());
System.out.println("换老师或者换放假");
}
}
}
其实我就想往命令行输入数字但是用EditPlus不会。。。应该怎么弄???
展开