To control the use of custom exceptions generated random number is not even! Hehe now review stage, the small circling the examples out on the share, the welcome given to criticizing

/**
 * 产生一个-100到100以内的随机数,判断这个随机数是不是偶数
 * @author Administrator
 *
 */
 class NotPlus extends Exception{
        public String notPlus(){
                String name="随机数不是正数";
                System.out.println(name);
                return name;
        }
        
        
}
class NotEven extends Exception{
        public String notEven(){
                String name="随机数不是偶数";
                System.out.println(name);
                return name;
        }
        
        
}

public class TestException {
   
        public void countNumber(int number)throws NotPlus,NotEven{
                if(number<0){
                        NotPlus np=new NotPlus();
                        np.notPlus();
                        
                }
                else if(number%2!=0){
                        NotEven ne=new NotEven();
                        ne.notEven();
                }
                
        }
        
        /**
         * @param args
         */
        public static void main(String[] args)  {
                // TODO Auto-generated method stub
                TestException testException=new TestException();
                int number=(int)(Math.random()*100);
                double temp=Math.random();
                if(temp<0.5){
                        number=-number;
                }
                System.out.println("temp="+temp);
                
                System.out.println("产生的随机数是"+number);
                try{
                        testException.countNumber(number);
                        
                }
                 catch (NotPlus e) {
                                e.notPlus();
                        }
                
                catch (NotEven e) {
                        e.notEven();
                }
        

}
}