i real need your help because i am trying to replace if and else with my code but i still a novice and gives me a hard time the below is my code i realy need your help plz because i have to present it.
Code: Select all
implement taskWindow
inherits applicationWindow
open core, vpiDomains
constants
mdiProperty : boolean = true.
clauses
new():-
applicationWindow::new(),
generatedInitialize().
constants
txt_input = "Eingabe".
domains
name = string.
disease = symbol.
indication = symbol.
predicates
onShow : window::showListener.
clauses
onShow(_, _CreationData):-
_MessageForm = messageForm::display(This).
predicates
onFileNew : window::menuItemListener.
clauses
onFileNew(_Source, _MenuTag):-
if Patient = commonDialogs::tryGet_string(This, txt_input, "", "What is the Patient's name ?") then
else
Patient = "unknown"
end if,
go(Patient).
predicates
go : (name Patient).
clauses
go(Patient) :-
checkPupil(Patient),
fail.
go(Patient) :-
gradePupil(Patient),
fail.
go(_Patient):-
stdIo::write("=====\n").
facts
symptom : (name,indication) nondeterm.
predicates
checkPatient : (name Patient)
multi.
clauses
checkPatient(Patient) :-
if commonDialogs::tryGet_string(This, txt_input, "", string::concat("Does ", Patient, " have a fever (y/n) ?")) = "y" then
assert(symptom(Patient, "fever"))
end if.
checkPatient(Patient) :-
if commonDialogs::tryGet_string(This, txt_input, "", string::concat("Does ", Patient, " have a rash (y/n) ?")) = "y" then
assert(symptom(Patient, "rash"))
end if.
checkPatient(Patient) :-
if commonDialogs::tryGet_string(This, txt_input, "", string::concat("Does ", Patient, " have a headache (y/n) ?")) = "y" then
assert(symptom(Patient, "headache"))
end if.
checkPatient(Patient) :-
if commonDialogs::tryGet_string(This, txt_input, "", string::concat("Does ", Patient, " have a fever (y/n) ?")) = "y" then
assert(symptom(Patient, "fever"))
end if.
checkPatient(Patient) :-
if commonDialogs::tryGet_string(This, txt_input, "", string::concat("Does ", Patient, " have a runny_nose (y/n) ?")) = "y" then
assert(symptom(Patient, "runny_nose"))
end if.
checkPatient(Patient) :-
if commonDialogs::tryGet_string(This, txt_input, "", string::concat("Does ", Patient, " have a conjunctivitis (y/n) ?")) = "y" then
assert(symptom(Patient, "conjunctivitis"))
end if.
checkPatient(Patient) :-
if commonDialogs::tryGet_string(This, txt_input, "", string::concat("Does ", Patient, " have a cough (y/n) ?")) = "y" then
assert(symptom(Patient, "cough"))
end if.
checkPatient(Patient) :-
if commonDialogs::tryGet_string(This, txt_input, "", string::concat("Does ", Patient, " have a body_ache (y/n) ?")) = "y" then
assert(symptom(Patient, "body_ache"))
end if.
checkPatient(Patient) :-
if commonDialogs::tryGet_string(This, txt_input, "", string::concat("Does ", Patient, " have a chills (y/n) ?")) = "y" then
assert(symptom(Patient, "chills"))
end if.
checkPatient(Patient) :-
if commonDialogs::tryGet_string(This, txt_input, "", string::concat("Does ", Patient, " have a sore_throat (y/n) ?")) = "y" then
assert(symptom(Patient, "sore_throat"))
end if.
checkPatient(Patient) :-
if commonDialogs::tryGet_string(This, txt_input, "", string::concat("Does ", Patient, " have a sneezing (y/n) ?")) = "y" then
assert(symptom(Patient, "sneezing"))
end if.
checkPatient(Patient) :-
if commonDialogs::tryGet_string(This, txt_input, "", string::concat("Does ", Patient, " have a swollen_glands (y/n) ?")) = "y" then
assert(symptom(Patient, "swollen_glands"))
end if.
predicates
gradeDisease : (name Patient) nondeterm.
clauses
gradeDisease(Patient) :-
hypothesis(Patient, Disease),
stdIo::write(Patient, " ", Disease, "\n").
predicates
hypothesis : (name Patient, disease indication [out])
nondeterm.
clauses
hypothesis(Patient, "measles") :-
symptom(Patient,fever),
symptom(Patient,cough),
symptom(Patient,conjunctivitis),
symptom(Patient,runny_nose),
symptom(Patient,rash).
hypothesis(Patient,german_measles) :-
symptom(Patient,fever),
symptom(Patient,headache),
symptom(Patient,runny_nose),
symptom(Patient,rash).
hypothesis(Patient,flu) :-
symptom(Patient,fever),
symptom(Patient,headache),
symptom(Patient,body_ache),
symptom(Patient,conjunctivitis),
symptom(Patient,chills),
symptom(Patient,sore_throat),
symptom(Patient,runny_nose),
symptom(Patient,cough).
hypothesis(Patient,common_cold) :-
symptom(Patient,headache),
symptom(Patient,sneezing),
symptom(Patient,sore_throat),
symptom(Patient,runny_nose),
symptom(Patient,chills).
hypothesis(Patient,mumps) :-
symptom(Patient,fever),
symptom(Patient,swollen_glands).
hypothesis(Patient,chicken_pox) :-
symptom(Patient,fever),
symptom(Patient,chills),
symptom(Patient,body_ache),
symptom(Patient,rash).
hypothesis(Patient,measles) :-
symptom(Patient,cough),
symptom(Patient,sneezing),
symptom(Patient,runny_nose).