/
hangman.ti83
142 lines (112 loc) · 1.53 KB
/
hangman.ti83
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
ClrHome
Output(3,5,"Hangman")
Output(4,6,"v 1.1"
Output(6,3,"(Press Enter)")
Pause
Lbl s
ClrHome
Input "Word? ", Str1
Disp " "
If length(Str1) > 16
Then
ClrHome
Disp "There is a","limit of","16 letters","","(Press enter)"
Pause
Goto s
End
Lbl a
Input "Chances? ",x
If X<=0 or X != int(x)
Then
ClrHome
Disp "Invalid number","of chances," ","(Press enter)"
Pause
ClrHome
Goto a
End
" "->Str3
" "->Str4
Lbl b
For(i,1,length(Str4),1)
If sub(Str4,i,1)=sub(Str1,1,1)
Then
sub(Str4,i,1)->Str0
Goto c
End
If i=length(Str4) and STr0 != sub(Str1,1,1)
Then
"-"->Str0
End
End
Lbl c
For(q,2,length(Str1),1)
For(i,1,length(Str4),1)
If sub(Str4,i,1)=sub(Str1,q,1)
Then
Str0+sub(Str4,i,1)->Str0
End
If i=length(Str4) and sub(Str0,length(Stro0,1) != sub(Str1,q,1)
Then
Str0+"-"->Str0
End
End
End
If Str0=STr1
Then
ClrHome
Output(4,5,"You won!")
Goto d
End
While X != 0
ClrHome
Disp Str0
Disp " "
Disp " "
Output(3,1,"Chance(s):")
Output(3,12,x)
Disp Str3
Disp " "
Input "Guess? ",Str2
If length(Str2)>1
Then
ClrHome
Disp "One letter,"at a time","","(Press enter)"
Pause
Goto b
End
If inString(Str3,Str2) != 0 or inString(Str4,Str2) != 0
Then
ClrHome
Disp "You've tried","",Str2,""
Disp "(Press enter)"
Pause
Else
If inString(Str1,Str2)=0
Then
x-1->x
Str3+Str2->Str3
Else
Str4+Str2->Str4
Goto b
End
End
End
ClrHome
Output(4,5,"You lost")
Lbl d
Output(5,3,"(Press enter)"
Pause
ClrHome
OUtput(2,1,"The word(s) was:")
Output(4,1,Str1)
Output(7,3,"(Press enter)")
Pause
ClrHome
Disp ""
Disp "Play again?"
Input "(Y/N) ",Str5
If Str5="Y"
Then
Goto S
Else
ClrHome