/
HangMan.pas
executable file
·1010 lines (983 loc) · 34.7 KB
/
HangMan.pas
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Program HangMan;
uses crt;
type
arraystring=array[1..100] of string;
arrayinteger=array[1..100] of integer;
var
Data:arraystring;
LoginID:arraystring;
LoginPassword:arraystring;
Name:arraystring;
Sex:arraystring;
IDPoints:arrayinteger;
Points:arraystring;
FontColor:arraystring;
dictionary:arraystring;
save:integer;
choice:string;
count:integer;
IDNo:integer;
countdictionary:integer;
correct:boolean;
Again:string;
Letter:char;
Level:integer;
hold:string;
hold2:string;
num:integer;
Gamefile:text;
Profile:text;
x:integer;
y:integer;
limitx:integer;
limity:integer;
num2:integer;
middle:integer;
top:integer;
bottom:integer;
qword:string;
aword:string;
playerpoints:integer;
marypoints:integer;
randompoint:integer;
procedure ChangeChar(var Change:char);{The procedure to change the letter into capital letter}
begin
if (Change>='a') and (Change<='z') then
Change:=Chr(Ord(Change)-32);
end;
procedure ChangeString(var Change:string); {The procedure to change the string into all capital letter}
begin
for num:=1 to length(Change) do
ChangeChar(Change[num]);
end;
procedure Checking(input:string;input2:string;var correct:boolean;typecheck:string);
{The procedure to check the input correct or not}
begin
ChangeString(typecheck);
correct:=false;
clrscr;
if typecheck='PW' then {To check the password}
begin
if LoginPassword[IDNo]=input then
correct:=true
else
begin
writeln('!!!!!!!!!!!WARNING!!!!!!!!!!!');
writeln('!! !!');
writeln('!! Invalid ID or password. !!');
writeln('!! Please try again. !!');
writeln('!! !!');
writeln('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
writeln;
writeln('Press <ENTER> to continue.');
readln;
end;
end;
if typecheck='DOUBLE' then {To check is the input1 same as input2}
begin
if input=input2 then
correct:=true
else
begin
writeln('!!!!!!!!!!!!WARNING!!!!!!!!!!!');
writeln('!! !!');
writeln('!! The inputs do not match. !!');
writeln('!! Please try again. !!');
writeln('!! !!');
writeln('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
writeln;
writeln('Press <ENTER> to continue.');
readln;
end;
end;
ChangeString(input);
ChangeString(input2);
if typecheck='CREATID' then {To check the ID had been used or not}
begin
correct:=true;
for count:=1 to count do
if LoginID[count]=input then
begin
correct:=false;
writeln('!!!!!!!!WARNING!!!!!!!!');
writeln('!! !!');
writeln('!! Inavail ID. !!');
writeln('!! Please try again. !!');
writeln('!! !!');
writeln('!!!!!!!!!!!!!!!!!!!!!!!');
writeln;
writeln('Press <ENTER> to continue');
readln;
end;
end;
if typecheck='ID' then {To check the ID}
begin
for count:=1 to count do
if LoginID[count]=input then
begin
correct:=true;
IDNo:=count;
end;
end;
if typecheck='SEX' then {To check the sex}
begin
if (input='M') or (input='F') then
correct:=true
else
begin
writeln('!!!!!!!!WARNING!!!!!!!!');
writeln('!! !!');
writeln('!! Invalid input. !!');
writeln('!! Please try again. !!');
writeln('!! !!');
writeln('!!!!!!!!!!!!!!!!!!!!!!!');
writeln;
writeln('Press <ENTER> to go back.');
readln;
end;
end;
if typecheck='CHOICE' then {To check the choice in the limit or not}
begin
Letter:='A';
if length(input)=1 then
Letter:=input[1]
else
Letter:='~';
if ('0'<Letter)and(Letter<=input2) then
correct:=true
else
begin
writeln('!!!!!!!!WARNING!!!!!!!!');
writeln('!! !!');
writeln('!! Invalid input. !!');
writeln('!! Please try again. !!');
writeln('!! !!');
writeln('!!!!!!!!!!!!!!!!!!!!!!!');
writeln;
writeln('Press <ENTER> to go back.');
readln;
end;
end;
if typecheck='YN' then {To check the Yes/No Question's answer}
begin
if input='Y' then
correct:=true
else if input<>'N' then
begin
writeln('!!!!!!!!WARNING!!!!!!!!');
writeln('!! !!');
writeln('!! Invalid input. !!');
writeln('!! Please try again. !!');
writeln('!! !!');
writeln('!!!!!!!!!!!!!!!!!!!!!!!');
writeln;
writeln('Press <ENTER> to go back.');
readln;
end;
end;
clrscr;
end;
procedure SaveRecord; {The procedure to Save the change}
begin
assign(Profile,'C:\EnglishGame\LoginID.txt');
rewrite(Profile);
for count:=1 to count do
begin
Str(IDPoints[count],Points[count]);
data[count]:=LoginID[count]+' '+LoginPassword[count]+' '+Name[count]+' '+Sex[count]+' '+Points[count]+' '+FontColor[count];
writeln(Profile, data[count]);
end;
close(Profile);
writeln('Your data had been saved.');
writeln;
writeln('Press <ENTER> to go back.');
readln;
save:=1;
end;
procedure ExitProgram; {The procedure before exit some pages when some data was changed}
begin
clrscr;
if save=0 then
begin
repeat
writeln('Your data had not been saved.');
write('Do you want to save it now? (Y/N) ');
readln(Again);
ChangeString(Again);
Checking(Again,'',correct,'YN');
if correct then
SaveRecord;
if Again='N' then
begin
writeln('!!!!!!!!!WARNING!!!!!!!!!');
writeln('!! !!');
writeln('!! Your data may lose. !!');
writeln('!! !!');
writeln('!!!!!!!!!!!!!!!!!!!!!!!!!');
writeln;
writeln('Are you sure not to save the data? (Y/N)');
readln(Again);
ChangeString(Again);
Checking(Again,'',correct,'YN');
clrscr;
end;
until Again='Y';
end;
clrscr;
end;
procedure Readdictionary; {The procedure to input the dictionary for the game to use}
begin
assign(Gamefile,'C:\EnglishGame\dictionary.txt');
reset(Gamefile);
countdictionary:=0;
while eof(Gamefile)=false do
begin
countdictionary:=countdictionary+1;
readln(Gamefile,dictionary[countdictionary]);
end;
close(Gamefile);
end;
procedure ChangeColor(color:string); {The procedure to change the font color}
begin
if color='Blue' then
begin
Textcolor(9);
FontColor[IDNo]:='Blue';
end;
if color='Green' then
begin
Textcolor(10);
FontColor[IDNo]:='Green';
end;
if color='PureBlue' then
begin
Textcolor(11);
FontColor[IDNo]:='PureBlue';
end;
if color='Red' then
begin
Textcolor(12);
FontColor[IDNo]:='Red';
end;
if color='Pink' then
begin
Textcolor(13);
FontColor[IDNo]:='Pink';
end;
if color='Yellow' then
begin
Textcolor(14);
FontColor[IDNo]:='Yellow';
end;
if color='White' then
begin
Textcolor(15);
FontColor[IDNo]:='White';
end;
end;
procedure Welcome; {The procedure for the first page welcome the user}
begin
randomize;
num:=1;
limitx:=70;
limity:=8;
repeat
for x := num to limitx do
begin
TextBackground(0);
Gotoxy(x,num);
delay(1);
if ((num=2)or(num=3)or(num=4))and((x=2)or(x=12)) then
write('W')
else if (num=4)and(x=7) then
write('W')
else if ((num=2)or(num=4))and((x=15)or(x=17)or(x=19)or(x=21)) then
write('E')
else if (num=3)and(x=14) then
writeln('E')
else if ((num=2)or(num=3)or(num=4))and(x=24) then
write('L')
else if (num=2)and((x=34)or(x=36)or(x=38)or(x=40)) then
write('C')
else if ((num=3)or(num=4))and(x=33) then
write('C')
else if (num=2)and((x=45)or(x=47)) then
write('O')
else if ((num=3)or(num=4))and((x=43)or(x=49)) then
write('O')
else if (num=2)and((x=53)or(x=59)) then
write('M')
else if (num=3)and((x=52)or(x=55)or(x=57)or(x=60)) then
write('M')
else if (num=4)and((x=52)or(x=56)or(x=60)) then
write('M')
else if ((num=2)or(num=4))and((x=63)or(x=65)or(x=67)or(x=69)) then
write('E')
else if (num=3)and(x=62) then
write('E')
else
write(' ');
end;
for y := (num+1) to limity do
begin
Gotoxy(limitx,y);
delay(1);
if ((y=2)or(y=4)or(y=6))and(limitx=69) then
write('E')
else
write(' ');
end;
for x := (limitx-1) downto num do
begin
Gotoxy(x,limity);
delay(1);
if (limity=5)and((x=7)or(x=11)) then
write('W')
else if (limity=6)and((x=5)or(x=9)) then
write('W')
else if (limity=5)and(x=14) then
writeln('E')
else if (limity=6)and((x=15)or(x=17)or(x=19)or(x=21)) then
write('E')
else if (limity=5)and(x=24) then
write('L')
else if (limity=6)and((x=24)or(x=26)or(x=28)or(x=30)) then
write('L')
else if (limity=5)and(x=33) then
write('C')
else if (limity=6)and((x=34)or(x=36)or(x=38)or(x=40)) then
write('C')
else if (limity=5)and((x=43)or(x=49)) then
write('O')
else if (limity=6)and((x=45)or(x=47)) then
write('O')
else if ((limity=5)or(limity=6))and((x=52)or(x=60)) then
write('M')
else if (limity=5)and(x=62) then
write('E')
else if (limity=6)and((x=63)or(x=65)or(x=67)) then
write('E')
else
write(' ');
end;
for y := (limity-1) downto (num+1) do
begin
Gotoxy(num,y);
delay(1);
if (num=2)and((y=3)or(y=4)) then
write('W')
else if (num=3)and(y=5) then
write('W')
else
write(' ');
end;
num:=num+1;
limitx:=limitx-1;
limity:=limity-1;
until (num=5);
Gotoxy(1,9);
writeln('Press <ENTER> to continue.');
readln;
end;
procedure Arrange; {The procedure to separate the data into ID, Password, Name, Sex and Points}
begin
for count:=1 to count do
begin
num:=0;
num2:=1;
hold2:=data[count]+' ';
repeat
hold:='';
num:=num+1;
while hold2[num2]<>' ' do
begin
hold:=hold+hold2[num2];
num2:=num2+1;
end;
num2:=num2+1;
if num=1 then
LoginID[count]:=hold;
if num=2 then
LoginPassword[count]:=hold;
if num=3 then
Name[count]:=hold;
if num=4 then
Sex[count]:=hold;
if num=5 then
Points[count]:=hold;
if num=6 then
FontColor[count]:=hold;
until num=6;
end;
end;
procedure ReadRecord(var count:integer; var data:arraystring); {The procedure to read the data of every ID}
begin
num:=0;
assign(Profile,'C:\EnglishGame\LoginID.txt');
reset(Profile);
count:=0;
while eof(Profile)=false do
begin
count:=count+1;
readln(Profile,data[count]);
Arrange;
Val(Points[count],IDPoints[count],num);
end;
close(Profile);
end;
procedure CreatAccount(var count:integer); {The procedure to create a new ID}
begin
clrscr;
repeat
write('Enter your ID: ');
readln(LoginID[count+1]);
ChangeString(LoginID[count+1]);
Checking(LoginID[count+1],'',correct,'CREATID');
until correct;
repeat
write('Enter your Password: ');
readln(LoginPassword[count+1]);
write('Please enter again: ');
readln(hold);
Checking(LoginPassword[count+1],hold,correct,'DOUBLE');
until correct;
count:=count+1;
Points[count]:='0';
FontColor[count]:='Green';
write('Enter your name: ');
readln(Name[count]);
ChangeString(Name[count]);
clrscr;
repeat
write('Enter your sex: (M/F) ');
readln(Sex[count]);
ChangeString(Sex[count]);
Checking(Sex[count],'',correct,'SEX');
until correct;
clrscr;
writeln('Here are your information:');
writeln('Login ID: ',LoginID[count]);
writeln('Login Password: ',LoginPassword[count]);
writeln('Name: ',Name[count]);
writeln('Sex: ',Sex[count]);
writeln('Points: 0');
writeln('Font Color: Green (Orginal Set)');
writeln;
writeln('Press <ENTER> to continue.');
readln;
clrscr;
save:=0;
end;
procedure Login(var count:integer); {The procedure of a page for user to Login}
begin
repeat
repeat
write('Do you have account?(Y/N) ');
readln(Again);
ChangeString(Again);
Checking(Again,'',correct,'YN');
if Again='N' then
CreatAccount(count);
until correct;
write('LoginID: ');
readln(hold);
write('Password: ');
readln(hold2);
ChangeString(hold);
Checking(hold,'',correct,'ID');
Checking(hold2,'',correct,'PW');
until correct;
ChangeColor(FontColor[IDNo]);
writeln('Welcome Back, ',Name[IDNo]);
writeln;
writeln('Press <ENTER> to continue.');
readln;
end;
procedure Rule; {The page telling the user about the rule of the game}
begin
writeln('Rule:');
writeln('===============================================');
writeln('First, there will give a word with blank, for example:');
writeln('A_ple');
writeln;
writeln('Then, you have to enter the correct letter, for example:');
writeln('P');
writeln;
writeln('If the answer is correct, you wil gain points!');
writeln('(The points you gain is according to your level)');
writeln;
writeln('If the answer is incorrect, you will lose point');
writeln('(You will only lose 1 point, whatever what level you are playing)');
writeln;
writeln('Enjoy!');
readln;
clrscr;
end;
procedure Question(var question:string); {The procedure to make the question}
begin
num:=0;
randomize;
num:=random(countdictionary)+1;
question:=dictionary[num];
num:=Level;
While num<>0 do
begin
num2:=random(length(question))+1;
if (question[num2]<>'_') then
begin
question[num2]:='_';
num:=num-1;
end;
end;
ChangeString(question);
writeln('Enter the missing letter in order: ', question);
end;
Procedure Answer(question:string;var answer:string); {The procedure for the user to answer the question}
begin
for Level:=1 to Level do
begin
write('Enter the missing letter in blank ',Level,': ');
readln(Letter);
ChangeChar(Letter);
num:=0;
repeat
num:=num+1;
if question[num]='_' then
begin
question[num]:=Letter;
num:=0;
end;
until num=0;
end;
answer:=question;
end;
Procedure checkanswer(answer:string;var pointget:integer); {The procedure to check whethever the answer is correct or not}
begin
correct:=false;
top:=1;
bottom:=countdictionary;
ChangeString(answer);
repeat
middle:=(top+bottom)div 2;
hold:=dictionary[middle];
ChangeString(hold);
if answer>hold then
top:=middle+1
else
if answer<hold then
bottom:=middle-1
else
correct:=true;
until correct or (top>bottom);
{This part is use to calculate and tell the user the change of his points}
if correct then
begin
writeln('You enter the correct answer!!');
writeln('You have gain ',Level,' points!!');
IDPoints[IDNo]:=IDPoints[IDNo]+Level;
writeln;
writeln('You now have ',IDPoints[IDNo],' points!!');
pointget:=pointget+Level;
end
else
begin
writeln('You enter the wrong answer -_-');
writeln('You have not gain any points -_-');
if IDPoints[IDNo]>0 then
IDPoints[IDNo]:=IDPoints[IDNo]-Level;
writeln;
writeln('You now have ',IDPoints[IDNo],' points!');
if pointget<>0 then
pointget:=pointget-1;
end;
writeln('Press <ENTER> to continue.');
readln;
clrscr;
save:=0;
end;
procedure PlayGame(var total:integer); {The procedure that include Question, Answer, and check Answer}
begin
Question(qword);
Answer(qword,aword);
clrscr;
checkanswer(aword,total);
end;
procedure Competition; {The procedure create a fighter to have competition with the user}
var
time:integer;
begin
playerpoints:=0;
marypoints:=0;
repeat
writeln('1. Level 1');
writeln('2. Level 2');
write('Which level do you want? ');
readln(choice);
Checking(choice,'2',correct,'CHOICE');
until correct;
Letter:=choice[1];
Level:=ord(Letter)-48;
write('How many times you want to play? ');
readln(time);
clrscr;
writeln('Lets play, your fighter is Mary!');
writeln('=================================================');
for time:=1 to time do
begin
writeln('Round ',time);
writeln('It is your term:');
Question(qword);
Answer(qword,aword);
clrscr;
num2:=0;
checkanswer(aword,num2);
writeln('In this round, you gain ',num2,' points!');
playerpoints:=playerpoints+num2;
readln;
clrscr;
writeln('It is Mary''s term:');
writeln;
randomize;
randompoint:=random(Level);
writeln('In this round, Mary gain ',randompoint,' points!');
marypoints:=marypoints+randompoint;
readln;
clrscr;
end;
writeln('In total, you get ',playerpoints,' point(s)');
writeln('In total, Mary gets ',marypoints,' point(s)');
If marypoints<=playerpoints then
begin
delay(500);
writeln('Y Y O U U W W I N N');
delay(500);
writeln('Y Y O O U U W W I N N N');
delay(500);
writeln(' Y O O U U W W W I N N N');
delay(500);
writeln(' Y O U U W W I N N');
end
else
begin
delay(500);
writeln('Y Y O U U L O S S S E E E');
delay(500);
writeln('Y Y O O U U L O O S E E E');
delay(500);
writeln(' Y O O U U L O O S E ');
delay(500);
writeln(' Y O U U L L L O S S S E E E');
end;
writeln('Press <ENTER> to go back.');
readln;
clrscr;
end;
procedure SelectPageGame; {The page for user to select how to play}
var
total:integer;
begin
Rule; {Introduce the rule of the game before play}
Again:='N';
Repeat
if Again='N' then
repeat
Writeln('Select the function:');
Writeln('1. Level 1');
Writeln('2. Level 2');
Writeln('3. Competition');
Writeln('4. Exit');
Write('Which function you want to use? ');
Readln(choice);
hold2:=choice;
clrscr;
Checking(choice,'4',correct,'CHOICE'); {To check is the choice enter correctly}
until correct;
if choice='1' then
Level:=1;
if choice='2' then
Level:=2;
Letter:=hold2[1];
case Letter of
'1','2':PlayGame(total);
'3':Competition;
'4':ExitProgram;
end;
if choice<>'4' then
repeat
write('Try again?(Y/N) ');
readln(Again);
ChangeString(Again);
Checking(Again,'',correct,'YN');
until (Again='Y')or(Again='N');
clrscr;
until choice='4';
end;
procedure ReadProfile; {The procedure to show the information of the user}
begin
writeln('ID No.: ',LoginID[IDNo]);
writeln('Name: ',Name[IDNo]);
writeln('Sex: ',Sex[IDNo]);
writeln('Points: ',IDPoints[IDNo]);
writeln('Font Color: ',Fontcolor[IDNo]);
writeln;
writeln('Press <ENTER> to go back.');
readln;
clrscr;
end;
procedure EditProfile; {The procedure to edit the profile}
var
hold1:string;
hold2:string;
begin
repeat
writeln('ID No.: ',LoginID[IDNo]);
writeln('Password: ',LoginPassword[IDNo]);
writeln('Name: ',Name[IDNo]);
writeln('Sex: ',Sex[IDNo]);
writeln('Points: ',IDPoints[IDNo]);
writeln('Font Color: ',Fontcolor[IDNo]);
writeln('================================================');
writeln('Select the function');
writeln('1. Edit the Password');
writeln('2. Edit the Name');
writeln('3. Edit the Sex');
writeln('4. Exit');
write('Which function you want to use? ');
readln(choice);
Checking(choice,'4',correct,'CHOICE');
clrscr;
while (choice<='3') and (correct)do
begin
if choice='1' then
write('You now want to change the Password? (Y/N) ');
if choice='2' then
write('You now want to change the Name? (Y/N) ');
if choice='3' then
write('You now want to change the Sex? (Y/N) ');
readln(Again);
ChangeString(Again);
Checking(Again,'',correct,'YN');
if correct then
begin
if choice='1' then
begin
repeat
writeln('The orginal Password: ',LoginPassword[IDNo]);
write('The new Password: ');
readln(hold1);
write('Please input again: ');
readln(hold2);
Checking(hold1,hold2,correct,'DOUBLE');
if correct then
LoginPassword[IDNo]:=hold1;
until correct;
end;
if choice='2' then
begin
repeat
writeln('The orginal Name: ',Name[IDNo]);
write('The new Name: ');
readln(hold1);
ChangeString(hold1);
write('Please input again: ');
readln(hold2);
clrscr;
ChangeString(hold2);
Checking(hold1,hold2,correct,'DOUBLE');
if correct then
Name[IDNo]:=hold1;
until correct;
end;
if choice='3' then
begin
repeat
writeln('The orginal Sex: ',Sex[IDNo]);
write('The new Sex: (M/F) ');
readln(hold1);
ChangeString(hold1);
write('Please input again: ');
readln(hold2);
ChangeString(hold2);
Checking(hold1,'',correct,'SEX');
if correct then
Checking(hold1,hold2,correct,'DOUBLE');
if correct then
Sex[IDNo]:=hold1;
until correct;
end;
writeln('The data have been changed.');
writeln;
writeln('Press <ENTER> to go back.');
readln;
clrscr;
End
else if Again<>'N' then
correct:=true;
End;
If Choice='4' Then
ExitProgram;
Until (Choice='4');
End;
Procedure Ranking; {The procedure shows the ranking of all the user}
Var
time,time2:integer;
begin
SaveRecord;
clrscr;
for time2:=1 to count do
for time:=time2 to count do
begin
if IDPoints[time2]<IDPoints[time] then
begin
hold:=LoginID[time2];
LoginID[time2]:=LoginID[time];
LoginID[time]:=hold;
hold:=Name[time2];
Name[time2]:=Name[time];
Name[time]:=hold;
hold:=Sex[time2];
Sex[time2]:=Sex[time];
Sex[time]:=hold;
hold:=Points[time2];
Points[time2]:=Points[time];
Points[time]:=hold;
end;
end;
for count:=1 to count do
writeln(Name[count],' ',Sex[count],' ',Points[count]);
writeln('Press <ENTER> to go back.');
readln;
ReadRecord(count,data);
end;
procedure Coupon; {The procedure for buying coupon}
begin
if IDPoints[IDNo]>=50 then
begin
IDPoints[IDNo]:=IDPoints[IDNo]-50;
SaveRecord;
writeln('The things will send to your home soon.');
end
else
begin
clrscr;
writeln('!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!');
writeln('!! !!');
writeln('!! You do not have enough points. !!');
writeln('!! You cannot buy it. !!');
writeln('!! You need ',50-IDPoints[IDNo],' more points. !!');
writeln('!! Please try again. !!');
writeln('!! !!');
writeln('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
end;
writeln;
writeln('Press <ENTER> to go back.');
readln;
clrscr;
end;
procedure Shop; {The procedure for user to select what to buy}
begin
repeat
writeln('Select the function');
writeln('1. coupon of Wellcome($50), need 50 points');
writeln('2. coupon of KKShop(20% off), need 50 points');
writeln('3. Exit');
write('Which function you want to use? ');
readln(choice);
Checking(choice,'3',correct,'CHOICE');
case Letter of
'1','2':Coupon;
'3':ExitProgram;
end;
until choice='3';
end;
procedure SelectColor; {The procedure for user to change the font color}
begin
repeat
repeat
writeln('Select the funtion:');
TextColor(10);
writeln('1. Green (Orginal Set)');
TextColor(9);
writeln('2. Blue');
TextColor(11);
writeln('3. Pure Blue');
TextColor(12);
writeln('4. Red');
TextColor(13);
writeln('5. Pink');
TextColor(14);
writeln('6. Yellow');
TextColor(15);
writeln('7. White');
ChangeColor(FontColor[IDNo]);
writeln('8. Exit');
write('Which function you want to use? ');
readln(choice);
Checking(choice,'8',correct,'CHOICE');
if (choice='1') or (choice='2') then
save:=0;
case Letter of
'1':ChangeColor('Green');
'2':ChangeColor('Blue');
'3':ChangeColor('PureBlue');
'4':ChangeColor('Red');
'5':ChangeColor('Pink');
'6':ChangeColor('Yellow');
'7':ChangeColor('White');
end;
clrscr;
until correct;
Again:='N';
if choice<>'8' then
writeln('The color have been changed.');
until choice='8';
ExitProgram;
choice:='';
end;
begin
Textbackground(0);
TextColor(10);
Readdictionary;
count:=0;
num:=0;
ReadRecord(count,data);
Welcome;
save:=1;
clrscr;
IDNo:=1;
Login(count);
clrscr;
repeat
writeln('Welcome, ',Name[IDNo]);
writeln('You now have ',Points[IDNo],' points');
writeln('=======================================');
writeln('Select the function');
writeln('1. Game (Fill in the blanks)');
writeln('2. Profile');
writeln('3. Edit Profile');
writeln('4. Ranking (The data will automatically save)');
writeln('5. Shop');
writeln('6. Save');
writeln('7. Change Font Color');
writeln('8. Exit');
write('Which function you want to use? ');
readln(choice);
clrscr;
Checking(choice,'8',correct,'CHOICE');
case Letter of
'1':SelectPageGame;
'2':ReadProfile;
'3':EditProfile;
'4':Ranking;
'5':Shop;
'6':SaveRecord;
'7':SelectColor;