Last active
March 10, 2018 01:43
-
-
Save matthew-gerstman/89471cf2e164720a0ba043b82d3d17af to your computer and use it in GitHub Desktop.
I wrote this program in the 8th grade to help me pick which chapter of which Harry Potter audiobook to fall asleep to.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Program HarryPotter (input,output); | |
Uses CRT; | |
Var | |
Book,Chapter,Last,test,index,PW,hold,High,Low,Multiple,v,Check:Integer; | |
Part:Char; | |
Unwanted:Array [1..4] of integer; | |
Procedure Matt; | |
Var | |
Chara:Array[1..80] of char; | |
index,y:integer; | |
x:char; | |
Begin | |
clrscr; | |
For y:= 9 to 80 do | |
Chara[y]:='0'; | |
Writeln('Enter your User Name iMatt711'); | |
Write('Password '); | |
index:=1; | |
Repeat | |
x:=readkey; | |
If (ord(x) <> 8) and (ord(x) <> 13) then | |
begin | |
Chara[index]:=x; | |
index:=index + 1; | |
write('*'); | |
end | |
else If (ord(x) = 8) then | |
Begin | |
chara[index - 1]:='0'; | |
If Index > 1 then | |
index:=index - 1 | |
else | |
index:= 1; | |
clrscr; | |
Writeln('Enter your User Name iMatt711'); | |
write('Password '); | |
If Index > 1 then | |
for y:=1 to (index - 1) do | |
write('*'); | |
end; | |
Until ord(x) = 13; | |
writeln; | |
// Redacted because my 8th grade plaintext password probably still opens _something_ | |
if (1==1) then | |
pw:=1 | |
else | |
Begin | |
pw:=0; | |
End; | |
For y:=9 to 80 do | |
If Chara[y] <> '0' then | |
Begin | |
pw:=0; | |
End; | |
If pw=1 then | |
Write('Press any key to begin') | |
else | |
Write('Wrong Password'); | |
delay(25); | |
Readkey; | |
End; | |
Procedure User; | |
Var | |
Chara:Array[1..80] of char; | |
index,y:integer; | |
x:char; | |
Begin | |
For y:= 9 to 80 do | |
Chara[y]:='0'; | |
Write('Enter your User Name '); | |
index:=1; | |
Repeat | |
x:=readkey; | |
If (ord(x) <> 8) and (ord(x) <> 13) then | |
begin | |
Chara[index]:=x; | |
index:=index + 1; | |
write(x); | |
end | |
else If (ord(x) = 8) then | |
Begin | |
chara[index - 1]:='0'; | |
If Index > 1 then | |
index:=index - 1 | |
else | |
index:= 1; | |
clrscr; | |
write('Enter your User Name '); | |
If Index > 1 then | |
for y:=1 to (index - 1) do | |
write(chara[y]); | |
end; | |
Until ord(x) = 13; | |
writeln; | |
if (chara[1] = 'i') and (chara[2] = 'M') and (chara[3] = 'a') and (chara[4] = 't') and (chara[5] = 't') and (chara[6] = '7') and (chara[7] = '1') and (chara[8] = '1') then | |
Begin | |
For y:=9 to 80 do | |
If Chara[y] <> '0' then | |
Begin | |
pw:=0; | |
End; | |
If Pw = 1 then | |
Matt; | |
End | |
else | |
Begin | |
pw:=0; | |
Write('Invailid User name '); | |
readkey; | |
End; | |
End; | |
Procedure Casualties; | |
Begin | |
User; | |
Clrscr; | |
If pw = 1 then | |
Begin | |
Writeln('Loading 5'); | |
Delay(750); | |
clrscr; | |
Writeln('Loading 4'); | |
Delay(750); | |
clrscr; | |
Writeln('Loading 3'); | |
Delay(750); | |
clrscr; | |
Writeln('Loading 2'); | |
Delay(750); | |
clrscr; | |
Writeln('Loading 1'); | |
Delay(750); | |
clrscr; | |
End; | |
End; | |
Begin | |
{Pre Op} | |
Randomize; | |
check := 0; | |
{Load casualties} | |
pw:=1; | |
test:=1; | |
If test = 1 then | |
casualties; | |
If pw = 1 then | |
Begin | |
{Pick Book} | |
Writeln('Are their any book(s) you don''t want to listen to? (0 for none) '); | |
Repeat | |
index:=index + 1; | |
Write('Book: '); | |
Multiple:=Multiple + 1; | |
Repeat | |
Readln(unwanted[index]); | |
If (Unwanted[index] <0) or (Unwanted[index] >5) then | |
Begin | |
Write('It must be between 1 and 5 or 0 for none'); | |
Readkey; | |
clrscr; | |
End; | |
Until (Unwanted[index] >= 0) and (Unwanted[index] <= 5); | |
Until (Unwanted[index] = 0) or (index = 4); | |
Repeat | |
Book:=Random(5) + 1; | |
Until (Book <> Unwanted[1]) and (Book <> Unwanted[2]) and (Book <> Unwanted[3]) and (Book <> Unwanted[4]); | |
Write('You are listening to Harry Potter and the '); | |
If Book=1 then | |
write('Philosopher''s Stone.') | |
Else if Book = 2 then | |
write('Chamber of Secrets.') | |
Else if Book = 3 then | |
write('Prisoner of Azkaban.') | |
Else If Book = 4 then | |
Write('Goblet of Fire.') | |
Else If Book = 5 then | |
Write('Order of the Phoenix.'); | |
delay(25); | |
readkey; | |
{Part} | |
clrscr; | |
Repeat | |
Write('What is the earliest chapter you want to listen to? '); | |
Readln(Low); | |
Write('What is the latest chapter you want to listen to? (0 for last) '); | |
Readln(High); | |
If (High < Low) and (High <> 0) then | |
Begin | |
Writeln('The earliest chapter must be smaller than the latest'); | |
delay(25); | |
Readkey; | |
End | |
else if (Low <=0) then | |
Begin | |
writeln('The earliest must be bigger than 0'); | |
delay(25); | |
Readkey; | |
End; | |
hold:=high; | |
If (Book = 1) and ((High > 17) or (High = 0)) then | |
high:=17; | |
If (Book = 2) and ((High > 18) or (High = 0)) then | |
high:=18; | |
If (Book = 3) and ((High > 22) or (High = 0)) then | |
high:=22; | |
If (Book = 4) and ((High > 37) or (High = 0)) then | |
high:=37; | |
If (Book = 5) and ((High > 38) or (High = 0)) then | |
high:=38; | |
delay(25); | |
readkey; | |
clrscr; | |
Until (High >= Low) and (Low >= 1); | |
If (Hold <> High) and (Hold <> 0) then | |
Writeln('The highest chapter you put is too big it will be converted to the last chapter') | |
else | |
Write('Press any key to continue '); | |
delay(25); | |
readkey; | |
clrscr; | |
{Picks Chapter} | |
chapter:=Low + Random(High - Low + 1); | |
Write('You are listening to Harry Potter and the '); | |
If Book=1 then | |
write('Philosopher''s Stone') | |
Else if Book = 2 then | |
write('Chamber of Secrets') | |
Else if Book = 3 then | |
write('Prisoner of Azkaban') | |
Else If Book = 4 then | |
Write('Goblet of Fire') | |
Else If Book = 5 then | |
Write('Order of the Phoenix'); | |
Write(' chapter ',chapter); | |
delay(25); | |
Readkey; | |
delay(2000); | |
Clrscr; | |
Writeln('Terminating in 5'); | |
Delay(750); | |
clrscr; | |
Writeln('Terminating in 4'); | |
Delay(750); | |
clrscr; | |
Writeln('Terminating in 3'); | |
Delay(750); | |
clrscr; | |
Writeln('Terminating in 2'); | |
Delay(750); | |
clrscr; | |
Writeln('Terminating in 1'); | |
Delay(750); | |
clrscr | |
End | |
Else | |
Begin | |
Clrscr; | |
Writeln('Terminating in 5'); | |
Delay(750); | |
clrscr; | |
Writeln('Terminating in 4'); | |
Delay(750); | |
clrscr; | |
Writeln('Terminating in 3'); | |
Delay(750); | |
clrscr; | |
Writeln('Terminating in 2'); | |
Delay(750); | |
clrscr; | |
Writeln('Terminating in 1'); | |
Delay(750); | |
clrscr; | |
End; | |
End. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment