对第一个程序的改进

原创 2007年10月02日 21:46:00

import java.lang.*;
import javax.swing.*;
/*import java.awt.*;
import java.applet.Applet;*/
public class AnimalIdentify1 {
 public AnimalIdentify1( ) {
 }
 
 /* 规则定义*/
 public  void rule1 ( ){
  int answer=JOptionPane.showConfirmDialog(null,"the animal doesn't have hair? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer==JOptionPane.YES_OPTION) 
     JOptionPane.showMessageDialog(null,"The animal is a mammal","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
   
 }

 public void rule2( ){
  int answer=JOptionPane.showConfirmDialog(null,"the animal doesn't galactopoiesis? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a mammal","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
   
 }  

 public void rule3( ){
  int answer=JOptionPane.showConfirmDialog(null,"the animal doesn't have feather? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a feather","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
   
 
 }
 public void rule4( ){
  int answer1=JOptionPane.showConfirmDialog(null,"the animal doesn't fly? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer2=JOptionPane.showConfirmDialog(null,"the animal doesn't lay Egg? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer1==JOptionPane.YES_OPTION&&answer2==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a feather","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
   
 }
 
 
 public void rule5( ){
  int answer1=JOptionPane.showConfirmDialog(null,"the animal isn't mammal? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer2=JOptionPane.showConfirmDialog(null,"the animal doesn't eat meat? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer1==JOptionPane.YES_OPTION&&answer2==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a carnivore","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
 }
 
 
 public void rule6( ){
  int answer1=JOptionPane.showConfirmDialog(null,"the animal isn't mammal? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer2=JOptionPane.showConfirmDialog(null,"the animal doesn't have claw? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer3=JOptionPane.showConfirmDialog(null,"the animal doesn't have sharptooth? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer4=JOptionPane.showConfirmDialog(null,"the animal isn't eyefrontad? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer1==JOptionPane.YES_OPTION&&answer2==JOptionPane.YES_OPTION&&answer3==JOptionPane.YES_OPTION&&answer4==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a carnivore","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
 }
 
 
 public void rule7( ){
  int answer1=JOptionPane.showConfirmDialog(null,"the animal isn't mammal? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer2=JOptionPane.showConfirmDialog(null,"the animal doesn't have hoof? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer1==JOptionPane.YES_OPTION&&answer2==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a ungulate","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
 }
  
 
 
    public void rule8( ){
  int answer1=JOptionPane.showConfirmDialog(null,"the animal isn't mammal? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer2=JOptionPane.showConfirmDialog(null,"the animal doesn't ruminate? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer1==JOptionPane.YES_OPTION&&answer2==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a ungulate and cloot","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
 }
  
  
 public void rule9( ){
  int answer1=JOptionPane.showConfirmDialog(null,"the animal isn't carnivore? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer2=JOptionPane.showConfirmDialog(null,"the animal isn't snuffcolored? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer3=JOptionPane.showConfirmDialog(null,"the animal isn't fuscous fleck? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer1==JOptionPane.YES_OPTION&&answer2==JOptionPane.YES_OPTION&&answer3==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a leopard","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
        System.exit(0);
 }
 
 
 public void rule10( ){
  int answer1=JOptionPane.showConfirmDialog(null,"the animal isn't carnivore? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer2=JOptionPane.showConfirmDialog(null,"the animal isn't snuffcolored? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer3=JOptionPane.showConfirmDialog(null,"the animal isn't black stripe? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer1==JOptionPane.YES_OPTION&&answer2==JOptionPane.YES_OPTION&&answer3==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a tiger","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
        System.exit(0);
 }
 
 
    public void rule11( ){
     int answer1=JOptionPane.showConfirmDialog(null,"the animal isn't ungulate? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer2=JOptionPane.showConfirmDialog(null,"the animal doesn't have long leg? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer3=JOptionPane.showConfirmDialog(null,"the animal doesn't have long neck? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer4=JOptionPane.showConfirmDialog(null,"the animal isn't snuffcolored? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer5=JOptionPane.showConfirmDialog(null,"the animal isn't fuscous fleck? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer1==JOptionPane.YES_OPTION&&answer2==JOptionPane.YES_OPTION&&answer3==JOptionPane.YES_OPTION&&answer4==JOptionPane.YES_OPTION&&answer5==JOptionPane.YES_OPTION)
        JOptionPane.showMessageDialog(null,"The animal is a giraffe","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
        System.exit(0);
 }
    
   
    public void rule12( ){
     int answer1=JOptionPane.showConfirmDialog(null,"the animal isn't ungulate? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer2=JOptionPane.showConfirmDialog(null,"the animal isn't white? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer3=JOptionPane.showConfirmDialog(null,"the animal isn't black stripe? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer1==JOptionPane.YES_OPTION&&answer2==JOptionPane.YES_OPTION&&answer3==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a zebra","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
        System.exit(0);
    }
   
    public void rule13( ){
     int answer1=JOptionPane.showConfirmDialog(null,"the animal isn't aves? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer2=JOptionPane.showConfirmDialog(null,"the animal isn't notfly? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer3=JOptionPane.showConfirmDialog(null,"the animal doesn't have long leg? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer4=JOptionPane.showConfirmDialog(null,"the animal doesn't have long neck? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer5=JOptionPane.showConfirmDialog(null,"the animal isn't blackandwhite? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer1==JOptionPane.YES_OPTION&&answer2==JOptionPane.YES_OPTION&&answer3==JOptionPane.YES_OPTION&&answer4==JOptionPane.YES_OPTION&&answer5==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a ostrich","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
        System.exit(0);
 }
   
   
    public void rule14( ){
     int answer1=JOptionPane.showConfirmDialog(null,"the animal isn't aves? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer2=JOptionPane.showConfirmDialog(null,"the animal isn't notfly? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer3=JOptionPane.showConfirmDialog(null,"the animal doesn't swim? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer4=JOptionPane.showConfirmDialog(null,"the animal isn't blackandwhite? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer1==JOptionPane.YES_OPTION&&answer2==JOptionPane.YES_OPTION&&answer3==JOptionPane.YES_OPTION&&answer4==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a penguin","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
        System.exit(0);
 }
     
   
    public void rule15( ){
        int answer1=JOptionPane.showConfirmDialog(null,"the animal isn't aves? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     int answer2=JOptionPane.showConfirmDialog(null,"the animal isn't be good at flying? In(Y/N)","AnimalIdentify",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
     if(answer1==JOptionPane.YES_OPTION&&answer2==JOptionPane.YES_OPTION) 
        JOptionPane.showMessageDialog(null,"The animal is a salangane","AnimalIdentify",JOptionPane.INFORMATION_MESSAGE);
        System.exit(0);
 }
  
     
   
   
   
    /*规则查询分析*/
    public void queryUseRule( ){
     JOptionPane.showMessageDialog(null,"please in your observing about the animal","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule1( );
        JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
        rule2( );
         JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule3( );
      JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule4( );
      JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule5( );
      JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule6( );
      JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule7( );
      JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule8( );
      JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule9( );
      JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule10( );
      JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule11( );
      JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule12( );
      JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule13( );
      JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule14( );
      JOptionPane.showMessageDialog(null,"continue observe","AnimalIdentiy",JOptionPane.INFORMATION_MESSAGE);
     rule15( );
   }
       /*主函数 */
      public static void main (String[ ] args){
       AnimalIdentify1 animal1=new AnimalIdentify1();
       animal1.queryUseRule();
    } 
}

对《Python核心编程》中“第一个Python程序”的改进

本程序主要是模仿《Python核心编程》中3.6节——第一个Python程序,并在其基础上做了一些小的改进,而改进的要求则是来源于第三章的课后练习题。 本篇博客的一个核心问题就是在我们如何避免重复制造...

我自己完成的第一个JAVA小程序改进版——银行业务调度系统Version2.0

看了张孝祥老师的讲解,对比自己完成的程序发现除了版本1红色字体标出的地方,还存在以下几点需要改进的地方: (1) 客户和服务的类型应该使用枚举类型,而自己是用数字1 2 3标记的,方法有点low。这里...

CentOS下安装QT5和编译第一个程序

QT5的安装 在安装QT5之前,首先要保证电脑里已经装了gcc和gcc-g++,只有gcc是不行的,因为QT5安装完成后会自动检测编译器,如果没有g++,它什么都不会检测到,它靠的编译器就是g++,...

我的第一个截图小程序

  • 2013年08月05日 09:23
  • 2KB
  • 下载

OC学习篇之---第一个程序HelloWorld

之前的一片文章简单的介绍了OC的相关概述,从这篇开始我们就开始学习OC的相关知识了,在学习之前,个人感觉需要了解的其他的两门语言:一个是C/C++,一个是面向对象的语言(当然C++就是面向对象,不过这...

我的第一个OpenGL程序

  • 2013年07月18日 20:47
  • 659KB
  • 下载

VC#初学入门:第一个Windows程序

  • 2012年11月05日 16:59
  • 68KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:对第一个程序的改进
举报原因:
原因补充:

(最多只允许输入30个字)