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();
}
}