PDA

View Full Version : Not the coolest thing ever...but kind of fun -



joeMan
02-16-2005, 10:04 PM
Here is how to get free Pascal:
How to Install Free Pascal on a Windows XP Computer

* go to www.freepascal.org
* click on Download
* click on "current site"
* click on Win32
* click on w321010.zip

After you click there, indicate that you want
to OPEN this file (instead of SAVE)

* There will be a long delay while the download
takes place.
* double click on "install.exe"

Indicate that you want to RUN this program
(if necessary)

* A window should pop up: click on "continue"
* After some time, you should see an
"install successful" message.
* Close the window

* Next:
* click on My Computer
* right click and select Properties
* click on advanced
* click on Environment Variables
* In the System Variables window, select Path
* click on Edit
* Carefully *add* this to what is already there:

;C:\pp\bin\win32

* click on OK
* click on OK a few more times to close the windows
that opened up

* Try to start Free Pascal:
* click on Start
* select All Programs
* select Accessories
* select Command Prompt
* type in this command: fp
* The Free Pascal window should pop up.
You can select File, then Exit to close it right away.
--------------------------------------------------------------------------

Here's a fun Roulette game we did for our last assignment, it's kinda cool if you feel up to going through these steps:
* Start up Notepad.
* Cut and paste the following program into Notepad (from the word "program" through the word "end."):



program roulette;

var choice, money: integer;

procedure menu(var ch: integer);
begin
writeln;
writeln('Options:');
writeln('1) bet on even number');
writeln('2) bet on odd number');
writeln('3) bet on low number 1-18');
writeln('4) bet on high number 19-36');
writeln('5) bet on 1st dozen 1-12');
writeln('6) bet on 2nd dozen 13-24');
writeln('7) bet on 3rd dozen 25-36');
writeln('8) exit');
writeln;
write('your choice: ');
readln(ch)
end;

procedure even(n, b: integer; var w: boolean; var a: integer);
begin
if (n mod 2) = 0 then
w := true
else
w := false;
if w = true then
a := (b)
else
a := (b)
end;

procedure odd(n, b: integer; var w: boolean; var a: integer);
begin
if (n mod 2) > 0 then
w := true
else
w := false;
if w = true then
a := (b)
else
a := (b)
end;

procedure low(n, b: integer; var w: boolean; var a: integer);
begin
if n < 19 then
w := true
else
w := false;
if w = true then
a := (b)
else
a := (b)
end;

procedure high(n, b: integer; var w: boolean; var a: integer);
begin
if n > 18 then
w := true
else
w := false;
if w = true then
a := (b)
else
a := (b)
end;

procedure firstDozen(n, b: integer; var w: boolean; var a: integer);
begin
if n < 13 then
w := true
else
w := false;
if w = true then
a := (b*2)
else
a := (b)
end;

procedure secondDozen(n, b: integer; var w: boolean; var a: integer);
begin
if (n > 12) and (n < 25) then
w := true
else
w := false;
if w = true then
a := (b*2)
else
a := (b)
end;

procedure thirdDozen(n, b: integer; var w: boolean; var a: integer);
begin
if (n > 24) and (n < 37) then
w := true
else
w := false;
if w = true then
a := (b*2)
else
a := (b)
end;

procedure oneSpin (var ch, m: integer);
var num: integer; bet: integer; win: boolean; amount: integer;
begin
writeln;
write('How much would you like to bet? ');
readln(bet);
num := 1 + random(36);
writeln( 'The wheel is spinning ...' );
writeln( '... and the ball stopped on number ', num);
case ch of
1: even(num, bet, win, amount);
2: odd(num, bet, win, amount);
3: low(num, bet, win, amount);
4: high(num, bet, win, amount);
5: firstDozen(num, bet, win, amount);
6: secondDozen(num, bet, win, amount);
7: thirdDozen(num, bet, win, amount);
end;
if win then
writeln('You won $', amount, '.')
else
writeln('You lost $', amount, '.');
if win then
m := m + amount
else
m := m - amount;
writeln('You have $', m)
end;

begin
randomize;
money := 100;
repeat
menu(choice);
if choice <> 8 then
oneSpin(choice, money);
until choice = 8
end.



* After you've pasted that program into Notepad, select File, then Save As
* Click the Desktop button on the left
* click the down arrow in the "Save as Type" box
and select "All Files"
* Enter "roulette.pas" for the filename
* Click on Save
* You can leave the Notepad window open or close it, doesn't matter.
* click on start, then Command Prompt
* A command prompt window will pop up.
* Type this command: cd Desktop
* Type this command: ppc386 roulette.pas
* Type this command: roulette
* The program should run a simple text roulette game.
Choose option 8 to end the game, then type exit at the prompt.