-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.scm
74 lines (71 loc) · 2.42 KB
/
main.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(require 'schelog)
(require 'database)
(require 'selector)
(require 'knowledgebase)
(require 'explainer)
(require 'querier)
(import schelog database selector knowledgebase explainer querier)
(use readline)
(current-input-port (make-gnu-readline-port))
(read-db "data")
(display "List of current customers: ")
(display %user-list)
(newline)
(let loop ()
; (display (string? x))
; (newline)
; (display (pair? x))
; (newline)
; (display (eval x))
(newline)
(display "Choose one of the options below:\n")
(display "[1]: Show the list of customers\n")
(display "[2]: Ask the expert system for suggestion on a customer's request\n")
(display "[3]: Ask for the expert system's explaination of the suggestion for a customer\n")
(display "[4]: Show all customers whose requests for credit should be accepted\n")
(display "[5]: Show all customers whose requests for credit should NOT be accepted\n")
(display "[6]: Show all customers that the expert system still hasn't had any definitive decision about their requests for credit\n")
(display "[0]: exit.\n")
(newline)
(let ((x (read)))
(if (or (not (number? x)) (< x 0) (> x 6))
(display "Invalid choice.\n\n")
(cond
[(= x 0) (display "\ngoodbye!") (newline) (exit)]
[(= x 1) (newline)(display %user-list) (newline)]
[(= x 2)
(display "\nEnter the name of the customer: \n")
(let ((name (read)))
(if (not (member name %user-list))
(begin
(display "\nInvalid customer name.\n")
(loop))
(begin
(newline)
(display "The evaluation of customer \[")
(display name)
(display "\] according to the expert system:\n")
(es:query name))))]
[(= x 3)
(display "\nEnter the name of the customer: \n")
(let ((name (read)))
(if (not (member name %user-list))
(begin
(display "\nInvalid customer name.\n")
(loop))
(expl:explain name)))]
[(= x 4)
(display "\nThe customers who are qualified for requesting credit: \n")
(es:outcome 'accept-credit-request)
(newline)]
[(= x 5)
(display "\nThe customers who are NOT qualified for requesting credit: \n")
(es:outcome 'refuse-credit-request)
(newline)]
[(= x 6)
(display "\nThe customers whom the system is unsure whether to give credit or not, and should be waited for superiors' direction:\n")
(es:outcome 'ask-superior-for-direction)
(newline)]
)))
(loop)
)