2014-10-24 3 views
0

현재 휴대 전화 용 CLips 프로그램을 작성 중입니다. 나는 다른 휴대폰과 그 스펙을 가지고있다. Color와 같은 기능을 분류하는 데 오류를 만드는 방법을 알아 내려고 노력 중입니다. 제가 아래에 무엇을 의미하는지 보여 드리겠습니다 :CLIPS의 인스턴스 및 슬롯

([phones_Class85] of Moto+X 

(Battery+Life "240") 
(Build+Material "Metal") 
(Camera "13") 
(Card+Slot "Yes") 
(Color "Cream") 
(FingerPrint+Scanner "No") 
(Memory "16") 
(Operating+System "Android") 
(Price "119") 
(RAM "1") 
(Screen+Size "5.2") 
(Water+Resistant "Yes") 
(Weight "144")) 

([phones_Class86] of IPhone+6 

(Battery+Life "250") 
(Build+Material "Metal") 
(Camera "8") 
(Card+Slot "No") 
(Color "Gold") 
(FingerPrint+Scanner "Yes") 
(Memory "16") 
(Operating+System "IOS") 
(Price "199") 
(RAM "1") 
(Screen+Size "4.7") 
(Water+Resistant "No") 
(Weight "129")) 


([phones_Class93] of IPhone+5s 

(Battery+Life "250") 
(Build+Material "Metal") 
(Camera "8") 
(Card+Slot "No") 
(Color "Gold") 
(FingerPrint+Scanner "Yes") 
(Memory "16") 
(Operating+System "IOS") 
(Price "99") 
(RAM "1") 
(Screen+Size "4") 
(Water+Resistant "No") 
(Weight "112")) 

다른 스펙의 인스턴스가있는 다른 휴대폰을 사용하고 있습니다. 더 많은 것이 있지만 나는 몇 가지를 주었다. 나는 색이 금인 모든 전화를 인쇄 할 수있는 허물을 가지고 뭔가를하려고 노력하고있다. 인스턴스가있을 때 이것을 통해 이동하는 방법을 잘 모르겠습니다. 인스턴스 내의 다른 슬롯 (컬러)에 액세스하여 각 슬롯을 검사하는 방법이 있습니까?

답변

1
CLIPS> 
(defclass Phone 
    (is-a USER) 
    (slot Battery+Life) 
    (slot Build+Material) 
    (slot Camera) 
    (slot Card+Slot) 
    (slot Color) 
    (slot FingerPrint+Scanner) 
    (slot Memory) 
    (slot Operating+System) 
    (slot Price) 
    (slot RAM) 
    (slot Screen+Size) 
    (slot Water+Resistant) 
    (slot Weight)) 
CLIPS> 
(defclass Moto+X 
    (is-a Phone)) 
CLIPS> 
(defclass IPhone 
    (is-a Phone)) 
CLIPS>  
(defclass IPhone+6 
    (is-a IPhone)) 
CLIPS>  
(defclass IPhone+5s 
    (is-a IPhone)) 
CLIPS> 
(definstances Phones 
    ([phones_Class85] of Moto+X 
     (Battery+Life "240") 
     (Build+Material "Metal") 
     (Camera "13") 
     (Card+Slot "Yes") 
     (Color "Cream") 
     (FingerPrint+Scanner "No") 
     (Memory "16") 
     (Operating+System "Android") 
     (Price "119") 
     (RAM "1") 
     (Screen+Size "5.2") 
     (Water+Resistant "Yes") 
     (Weight "144")) 

([phones_Class86] of IPhone+6 
     (Battery+Life "250") 
     (Build+Material "Metal") 
     (Camera "8") 
     (Card+Slot "No") 
     (Color "Gold") 
     (FingerPrint+Scanner "Yes") 
     (Memory "16") 
     (Operating+System "IOS") 
     (Price "199") 
     (RAM "1") 
     (Screen+Size "4.7") 
     (Water+Resistant "No") 
     (Weight "129")) 

([phones_Class93] of IPhone+5s 
     (Battery+Life "250") 
     (Build+Material "Metal") 
     (Camera "8") 
     (Card+Slot "No") 
     (Color "Gold") 
     (FingerPrint+Scanner "Yes") 
     (Memory "16") 
     (Operating+System "IOS") 
     (Price "99") 
     (RAM "1") 
     (Screen+Size "4") 
     (Water+Resistant "No") 
     (Weight "112"))) 
CLIPS>  
(defrule find-gold-phones 
    (object (is-a Phone) 
      (name ?name) 
      (Color "Gold")) 
    => 
    (printout t ?name " is a gold phone." crlf)) 
CLIPS>  
(defrule find-gold-iPhones 
    (object (is-a IPhone) 
      (name ?name) 
      (Color "Gold")) 
    => 
    (printout t ?name " is a gold iPhone." crlf)) 
CLIPS> (reset) 
CLIPS> (run) 
[phones_Class93] is a gold phone. 
[phones_Class93] is a gold iPhone. 
[phones_Class86] is a gold phone. 
[phones_Class86] is a gold iPhone. 
CLIPS>