【牛客带你学编程Java方向】项目练习第5期(参考答案)


参考答案:
public class Programme3 {
    public static void main(String[] args){
        Player player=new Player();
        try {
            player.play(11);
        } catch (NoThisSoundException e) {
            System.out.println(e.getMessage());
        }
    }
}

class NoThisSoundException extends Exception{
    NoThisSoundException(){
        super();
    }
    NoThisSoundException(String message){
        super(message);
    }
}
class Player{
    void play(int index) throws NoThisSoundException{
        if(index>10){
            throw new NoThisSoundException("您播放的歌曲不存在");
        }
    }
}

Tips:
全部评论

相关推荐

02-16 01:39
南昌大学 Java
重剑Ds:感觉不太可能 后端都减飞了 根本不缺人
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务