Subversion Repositories programming

Rev

Rev 124 | Rev 127 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 124 Rev 125
Line 18... Line 18...
18
#
18
#
19
#   -- 2005-10-08 2352
19
#   -- 2005-10-08 2352
20
#       Changed double quotes to single quotes.
20
#       Changed double quotes to single quotes.
21
#       Fixed a few small errors in the error handling code.
21
#       Fixed a few small errors in the error handling code.
22
#
22
#
-
 
23
#   -- 2005-10-09 0006
-
 
24
#       Made verbose mode into a toggle.
-
 
25
#
23
 
26
 
24
import sys, string
27
import sys, string
25
 
28
 
26
class automaton:
29
class automaton:
27
    
30
    
Line 45... Line 48...
45
        while not done:
48
        while not done:
46
            print 'Menu:'
49
            print 'Menu:'
47
            print '========================================'
50
            print '========================================'
48
            print '1. Enter an automaton'
51
            print '1. Enter an automaton'
49
            print '2. Run automaton'
52
            print '2. Run automaton'
50
            print '3. Enable Verbose Mode'
53
            print '3. %s Verbose Mode' % (self.verbose and 'Disable' or 'Enable', )
51
            print '4. Disable Verbose Mode'
-
 
52
            print '5. Quit'
54
            print '4. Quit'
53
            print
55
            print
54
            s = raw_input('Choice >>> ')
56
            s = raw_input('Choice >>> ')
55
            print
57
            print
56
 
58
 
57
            if s == '1':
59
            if s == '1':
Line 66... Line 68...
66
                    print
68
                    print
67
                else:
69
                else:
68
                    print 'Enter an automaton first!'
70
                    print 'Enter an automaton first!'
69
                    print
71
                    print
70
            elif s == '3':
72
            elif s == '3':
71
                self.verbose = True
73
                self.toggle_verbose()
72
                print 'Verbose Mode Enabled!'
74
                print 'Verbose Mode %s!' % (self.verbose and 'Enabled' or 'Disabled', )
73
                print
75
                print
74
            elif s == '4':
76
            elif s == '4':
75
                self.verbose = False
-
 
76
                print 'Verbose Mode Disabled!'
-
 
77
                print
-
 
78
            elif s == '5':
-
 
79
                done = True
77
                done = True
80
            else:
78
            else:
81
                print 'Bad Selection'
79
                print 'Bad Selection'
82
                print
80
                print
83
 
81
 
Line 216... Line 214...
216
        except ValueError:
214
        except ValueError:
217
            retVal = False
215
            retVal = False
218
 
216
 
219
        return retVal
217
        return retVal
220
 
218
 
221
    def enable_verbose(self):
219
    def toggle_verbose(self):
222
        self.verbose = True
220
        if self.verbose:
223
 
-
 
224
    def disable_verbose(self):
221
            self.verbose = False
-
 
222
        else:
225
        self.verbose = False
223
            self.verbose = True
226
 
224
 
227
### The "main" function
225
### The "main" function
228
if __name__ == '__main__':
226
if __name__ == '__main__':
229
    a = automaton()
227
    a = automaton()
230
    a.main_menu()
228
    a.main_menu()