如何将毕向东的Java异常处理练习改编成长尾词?

2026-04-02 02:431阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计313个文字,预计阅读时间需要2分钟。

如何将毕向东的Java异常处理练习改编成长尾词?

javapackage Lianxi;

class LanPingException extends Exception { public LanPingException(String message) { super(message); }}

如何将毕向东的Java异常处理练习改编成长尾词?

class MaoYanException extends Exception { public MaoYanException(String message) { super(message); }}

class NoPlanException extends Exception { public NoPlanException() { super(); }}


package Lianxi;
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 Computer
{
private int state= 3;
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("讲课");
}
public void test()
{
System.out.println("lianxi");
}
}
public class Demo001 {
public static void main(String [] args)
{
Teacher t = new Teacher("张老师");
try
{
t.prelect();
}
catch(NoPlanException e)
{
System.out.println(e.toString());
System.out.println("换老师,或者换电脑或者放假");
}
}


}


本文共计313个文字,预计阅读时间需要2分钟。

如何将毕向东的Java异常处理练习改编成长尾词?

javapackage Lianxi;

class LanPingException extends Exception { public LanPingException(String message) { super(message); }}

如何将毕向东的Java异常处理练习改编成长尾词?

class MaoYanException extends Exception { public MaoYanException(String message) { super(message); }}

class NoPlanException extends Exception { public NoPlanException() { super(); }}


package Lianxi;
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 Computer
{
private int state= 3;
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("讲课");
}
public void test()
{
System.out.println("lianxi");
}
}
public class Demo001 {
public static void main(String [] args)
{
Teacher t = new Teacher("张老师");
try
{
t.prelect();
}
catch(NoPlanException e)
{
System.out.println(e.toString());
System.out.println("换老师,或者换电脑或者放假");
}
}


}