Creeaza.com - informatii profesionale despre


Evidentiem nevoile sociale din educatie - Referate profesionale unice
Acasa » referate » informatica » calculatoare
Lucrare de specialitate - loto in limbajul pascal

Lucrare de specialitate - loto in limbajul pascal


LICEUL TEORETIC ANDREI BARSEANU

TARNAVENI

LUCRARE DE SPECIALITATE

LOTO



CUPRINS:

Tematica programului

De ce limbajul Pascal?

Rularea programului si interfata cu utilizatorul

Bibliografie

Listarea programului

1. Tematica programului

Loto este un program care simulaeza jocul 'loto 6/49'.A fost scris in Turbo Pascal 7.0 avand o singura deosebire: utilizatorul poate sa introduca mai multe numere identice in acelasi bilet

2. De ce limbajul Pascal?

Limbajul de programare Pascal a fost elaborat de Niklaus Wirth, profesor la Universitatea Tehnica din Zurich, Elvetia si a fost prezentat in revista Acta informatica 1 in 1970.

Limbajul Pascal a fost numit asa pentru a cinsti memoria celui care, pe langa multe alte realizari, a fost printre primii constructori de masini de calcul. Facilitatile de programare oferite de limbajul Pascal au facut ca acesta sa fie de la inceput larg raspandit, deoarece in acea perioada foamea de produse informatice era notabila, el ramanand si astazi un limbaj de programare universal des utilizat.

Elementele limbajului standard Pascal au fost imbogatite substantial, iar limbajul astfel obtinut a fost denumit Turbo Pascal, atributul Turbo referindu-se la rapiditatea compilatorului. La raspandirea limbajului a contribuit firma americana Borland, care a elaborat un compilator pe calculatoarele IBM-PC, compilator care contine in afara de un editor de texte si un asamblor integrat. Desi limbajuul initial a fost proiectat pentru scopuri didactice, posibilitatile oferite depasesc acest cadru.

Caracteristicile cele mai importante ale limbajului Pascal:

este tipizat, oferind o gama variata de tipuri predefinite, precum si posibilitatea definirii tipurilor utilizator, cu controale extinse asupra legalitatii utilizarii datelor;

este modularizat, asigurand un control riguros asupra vizibilitatii numerelor din program;

existenta unui numar mare de proceduri si functii predefinite;

posibilitatea divizarii unui program complex in piese relativ independente, care sa poata fi programate si compilate separat.

3. Rularea programului si interfata cu utilizatorul

Prima imagine care apare pe ecranul utilizatorului in momentul rularii programului este aceea a meniuilui principal. Acesta se prezinta sub forma a sase optiuni fieracare reprezentand cate o operatie pe care programul o poate face. La inceput, este selectata prima optiune. Deplasarea prin meniu si selectarea diferitelor optiuni se face cu ajutorul tastelor direcsionale "sus" respective "jos". Lansarea in executie a operatiei selectate se face cu tasta "Enter

Intreaga interfata cu utilizatorul a fost construiti folosind procedurile descries in unit-ul CRT al mediului integrat Turbo Pascal: gotoxy, textbackground, textcolor, sound, delay, nosound.

I Lista CASTIGATORI

Prima optiune din meniu determina afisarea castigatorilor la toate categoriile.

Afisarea se face pe rand pentru fiecare castigator in parte.

Revenirea la meniul principal al programului se face prin apasarea tastei "Enter

II ADAUGA BILET

Cea de-a doua optiune din meniul principal al programului, "ADAUGA BILET" conduce la afisarea unui formular cu datele de intrare ce trebuiesc completate: numele jucatorului impreuna cu cele 6 numere alese de el.

Programul testeaza daca numele introduse de jucator se afla in intervalul 1..49 in caz afirmativ continuandu-se executia programului.

III EXTRAGERE

Executand aceasta optiune programul va genera 6 numere castigatoare, care vor fi ulterior comparate cu datele introduse de jucator. Algoritmul de extragere a numerelor castigatoare este un bazat pe functiile Randomize si Random care genereaza aleator cele 6 numere.

IV REGULAMENT

In acesta sectiune jucatorul poate sa citesca regulamentul jocului Loto. Este indicata citirea regulamentului la prima executie a programului.

V NEW GAME

Cu ajutorul acestei optiuni se poate reseta jocul. Astfel se sterg din memorie toate datele anterioare despre bilete si jucatori.

VI DESPRE

In acesta sectiune se afseaza informatii despre program precum si numele programatorului: Suto Emil Razvan.

VII IESIRE

Ultima optiune disponibila este aceea de iesire din program.

BIBLIOGRAFIE:

Bogdan Patrut - Manual de informatica pentru clasa a IX-a. Algoritmi si limbaje de programare, Editura Teora, Bucuresti, 1998

Livia Toca, Andreea - Ruxandra Demco, Cristian Opincaru si Adrian Sindile - Informatica, Manual pentru clasa a X-a, Editura Niculescu, Bucuresti, 2001

Deaniela Oprescu, Liana Bejan Ienulescu, Viorica Patrascu - Informatica, Manual pentru clasa a XI-a, Varianta Pascal, Editura Niculescu, Bucuresti, 2002


5. Listarea programului

Program loto;

Uses

Gui,

Main,

Crt,

Dos;

Type vector=array[1..6]of byte;

vect=array[1..7]of string;

bilet=record

cod:byte;

nume:string;

numere:vector;

End;

Const

days : array [0..6] of String[9] =

('Duminica','Luni','Marti',

'Miercuri','Joi','Vineri',

'Sambata');

Var sir:array [1..40]of bilet;

i,j:byte;

s:vector;

nr,n,k, contor:byte ;

repetat: boolean;

ch2, ch:char;

v:vect;

z1, counter:byte;

Procedure data;

var

y, m, d, dow : Word;

begin

GetDate(y,m,d,dow);

GoToXY(60,1);

textcolor(0);

Writeln( days[dow], ' ', d:0, '/', m:0, '/', y:0);

end;

Procedure texte;

Begin

Textcolor(11);

Textbackground(11);

GoTOXY(4,5);

Write('.LIST-CASTIGATORI ');

GoTOXY(4,7);

Write('.ADAUGA BILET ');

GoTOXY(4,9);

Write('.EXTRAGERE ');

GoToXY(3,10);

wRITE('ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ') ;

GoTOXY(4,11);

Write('.REGULAMENT :: ');

GoTOXY(4,13 );

Write('.NEW GAME :: ');

GoTOXY(4,15);

Write('.DESPRE :: ');

GoToXY(3,16);

Write('ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ') ;

GoTOXY(4,17);

Write('.EXIT ');

End;

Procedure surfing(i:byte);

Begin

Textbackground(11);

Textcolor(11);

case i of

1:

Begin

Gotoxy(36,5);

Write( 'Afiseaza lista castigatorilor');

End ;

2:

Begin

Gotoxy(36,5);

Write( 'Adauga un bilet nou');

End;

3:

Begin;

Gotoxy(36,5);

Write( 'Se realizeaza extragerea celor 6 numere');

Gotoxy(36,6);

Write( 'de catre calculator');

End ;

4:

Begin;

Gotoxy(36,5);

Write( 'Regulamentul concursului');

End ;

5:

Begin;

Gotoxy(36,5);

Write( 'Se incepe un joc nou,resetandu-se ');

Gotoxy(36,6);

Write('baza de date ')

End ;

6:

Begin;

Gotoxy(36,5);

Write( 'Despre programul Loto ');

End ;

7:

Begin;

Gotoxy(36,5);

Write( 'Iesire din program ');

End ;

End;

End;

Procedure castigatori;

Begin

creare_castigatori;

afisare_castigatori;

Repeat

Textbackground(11);

Textcolor(11);

Gotoxy(47,3);

Write( ' Castigatori ');

textcolor(yellow+128);

GoToXY(40,17);

Write(' Apasa spatiu pt continuare ! ');

textcolor(11);

Until keypressed;

GoToXy(47,3);

write('ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ') ;

clear_win;

End;

Procedure adauga_bilet;

Begin

Adaugare;

Repeat

Textbackground(11);

Textcolor(11);

Gotoxy(47,3);

textcolor(yellow+128);

GoToXY(40,17);

Write(' Apasa spatiu pt continuare ! ');

textcolor(11);

Until keypressed;

GoToXy(47,3);

write('ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ') ;

clear_win;

End;

Procedure extragere2;

Begin

extragere;

Repeat

Textbackground(11);

Textcolor(11);

Gotoxy(47,3);

Write(' Extragere ');

textcolor(yellow+128);

GoToXY(40,17);

Write(' Apasa spatiu pt continuare ! ');

textcolor(11);

until Keypressed;

GoToXy(47,3);

write('ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ') ;

clear_win;

End;

Procedure despre;

Begin

clear_win;

Repeat

Textbackground(11);

Textcolor(11);

Gotoxy(49,3);

Write( ' Despre ');

GoToXY(40,5);

Write('Programul Loto vrea sa fie doar un');

GoToXY(35,6);

Write('simulator');

GoToXY(40,7);

Write('A fost scris pt. a servi ca program') ;

GoToXY(35,8);

Write('de atestat.');

GoToXY(40,9);

Write('Pt.mai multe informatii consultati') ;

GoToXY(35,10);

Write('fisierul help.txt. ') ;

GoToXY(40,13);

Write(' Programator: Suto Emil Razvan');

textcolor(yellow+128);

GoToXY(40,17);

Write(' Apasa spatiu pt continuare ! ');

textcolor(11);

Until keypressed;

GoToXy(47,3);

write('ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ') ;

clear_win;

End;

Procedure regulament;

Begin

clear_win;

Repeat

Textbackground(11);

Textcolor(11);

Gotoxy(49,3);

Write( ' Rgulamet ');

GoToXY(36,5);

Write('Acest program simuleaza jocul de loto');

GoTOXy(35,6);

Write('6 din 49 avand o singura deosebire:');

GoToXY(35,7);

Write('utilizatorul poate sa introduca mai multe');

GoToXY(35,8);

Write('numere identice in acelasi bilet.');

textcolor(yellow+128);

GoToXY(40,17);

Write(' Apasa spatiu pt continuare ! ');

textcolor(11);

Until keypressed;

GoToXy(47,3);

write('ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ') ;

clear_win;

End;

Procedure new;

Begin

clear_win;

new_game;

Repeat

Textbackground(11);

Textcolor(11);

Gotoxy(47,3);

Write( ' New game ');

GoToXY(40,5);

Write(' Jocul a fost resetat');

textcolor(yellow+128);

GoToXY(40,17);

Write(' Apasa spatiu pt continuare ! ');

textcolor(11);

Until keypressed;

GoToXy(47,3);

write('ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ') ;

clear_win;

End;

Begin

TextMode(c80);

Clrscr;

Hidecursor;

Assign(f,'castig.dat');

new_game;

Design;

desktop;

data;

window1;

Texte ;

v[1]:='.LIST-CASTIGATORI ' ;

v[3]:='.EXTRAGERE ' ;

v[2]:='.ADAUGA BILET ' ;

v[4]:='.REGULAMENT :: ' ;

v[5]:='.NEW GAME :: ' ;

v[6]:='.DESPRE :: ' ;

v[7]:='.EXIT ' ;

repeat

Texte;

Gotoxy(4,5);

Textbackground(1);

Write(v[1]);

Counter:=1 ;

surfing(counter) ;

z1:=5;

Repeat

ch:=readkey;

case cH of

#80 :

begin

textcolor(11);

textbackground(11);

gotoxy(4,z1);

write(V[COUNTER]);

surfing(counter);

COUNTER:=COUNTER+1;

z1:=z1+2;

clear_win;

if counter>7 then counter:=counter-7;

if z1>17 then z1:=5;

textcolor(11);

textbackground(1);

gotoxy(4,z1);

write(v[counter]);

surfing(counter);

end;

#72 : begin

textcolor(11);

textbackground(11);

gotoxy(4,z1);

write(v[counter]);

surfing(counter);

counter:=counter-1;

z1:=z1-2;

clear_win;

if counter<1 then counter:=7-counter;

if z1<5 then z1:=17;

textcolor(11);

textbackground(1);

gotoxy(4,z1);

write(v[counter]);

surfing(counter);

end;

end;

until ch=#13;

case counter of

1 :castigatori;

2 :adauga_bilet;

3 :extragere2;

4 :regulament;

5 :new;

6 :despre;

7 :exit;

End;

until COUNTER=7 ;

readkey;

End.

Unit GUI;

Interface

Uses

Crt;

Procedure hidecursor;

Procedure design;

Procedure desktop;

Procedure window1;

Procedure clear_win;

Implementation

Procedure hidecursor;

assembler;

asm

mov ax,$0100;

mov cx,$2607;

int $10

end;

Procedure design;

var i,j:byte;

Begin

textbackground(11);

textcolor(yellow);

for i:=1 to 80 do

Begin

GoToxy(i,1) ;

write(' ');

GoToxy(i,24) ;

write('Ϋ' );

End;

textcolor(yellow);

GoToxy(2,1) ;

write('LoTo:) ' );

textbackground(11);

textcolor(1);

For i:=1 to 80 do

For j:=2 to 23 do

Begin

GoToXy(i,j);

Write('²')

End;

End;

Procedure desktop;

var i,j:byte ;

Begin

textbackground(11);

textcolor(11);

For i:=2 to 23 do

For j:=3 to 19 do

Begin

GoToXy(i,j);

Write(' ')

End;

textcolor(blue);

textbackground(0);

For i:=4 to 25 do

Begin

GoToXy(i,20);

Write('°')

End;

textcolor(blue);

textbackground(0);

For i:=4 to 20 do

Begin

GoToXy(25,i);

Write('°°')

End;

textcolor(11) ;

textbackground(11);

for i:=3 to 23 do

Begin

GoToXy(i,3);

write('Ν') ;

GoToXy(i,19);

write('Ν ') ;

End;

gotoxy(8,3);

Write( '[ MENIU ]');

For j:=4 to 18 do

begin

GoToXY(2,j);

Write(' s ');

GoToXY(23,j);

Write('s')

End;

GoToXY(3,3);

Write('Ι') ;

GoToXY(3,19);

Write('Θ');

GoToXY(23,3);

Write('»') ;

GoToXY(23,19);

Write('Ό') ;

end;

Procedure clear_win;

var i,j:byte ;

Begin

For i:=34 to 75 do

For j:= 4 to 18 do

Begin

GoToXy(i,j);

Write(' ');

End;

End ;

Procedure window1;

var i,j:byte ;

Begin

For i:=32 to 77 do

For j:= 3 to 19 do

Begin

GoToXy(i,j);

Write(' ');

End;

textcolor(11) ;

textbackground(11);

for i:=33 to 76 do

Begin

GoToXy(i,3);

write('Ν') ;

GoToXy(i,19);

write('Ν ') ;

End;

For j:=4 to 18 do

begin

GoToXY(32,j);

Write(' s ');

GoToXY(76,j);

Write('s')

End;

GoToXY(33,3);

Write('Ι') ;

GoToXY(33,19);

Write('Θ');

GoToXY(76,3);

Write('»') ;

GoToXY(76,19);

Write('Ό') ;

textcolor(blue);

textbackground(0);

For i:=34 to 77 do

Begin

GoToXy(i,20);

Write('°°')

End;

textcolor(blue);

textbackground(0);

For i:=4 to 20 do

Begin

GoToXy(78,i);

Write('°°')

eND;

End;

Begin

End.

Unit Main;

Interface

Uses

Crt,

Dos,

Gui;

Type

vector=array[1..6]of byte;

bilet=record

cod:byte;

nume:string;

numere:vector;

categorie:byte;

End;

var sir:array [1..40]of bilet;

f :file of bilet;

a : bilet;

v,s : vector;

i,j,nr,n : integer;

repetat,

kk : boolean;

ch2,ch : char;

z1,counter: byte;

Procedure extragere;

Procedure adaugare;

Procedure afisare(i:integer);

Procedure creare_castigatori;

Procedure afisare_castigatori;

Procedure new_game;

Implementation

Procedure extragere;

var k:byte;

nn:byte;

Begin

Textbackground(11);

Textcolor(11);

clear_win;

Gotoxy(47,3);

Write( ' Extragere ');

Gotoxy(45,4);

Write( '-Numerele extrase-');

Gotoxy(43,3);

Textbackground(11);

Textcolor(11);

Randomize;

i:=1 ;

nn:=6;

while i<=6 do

Begin

nr:=Random(50);

s[i]:=nr;

i:=i+1;

GoToXy(wherex+2,7);

Write (nr);

delay(222)

End;

End;

procedure adaugare;

var jj,aux:byte;

hh:char;

begin

clear_win;

Textbackground(11);

Textcolor(11);

Gotoxy(47,3);

Write( ' Adauga bilet ');

Gotoxy(36,7);

Textbackground(blue);

Write(' ');

Textbackground(11);

n:=n+1;

gotoxy(36,5);

Write('Nr biletului :',n);

sir[n].cod:=n;

Repeat

gotoxy(36,6); Textbackground(11);

Write('Numele si prenumele:');

Textbackground(blue);

gotoxy(36,7);

Readln(sir[n].nume);

Until (IOResult=0)and(sir[n].nume<>'');

jj:=1 ;

Repeat

Repeat

Textbackground(11);

gotoxy(36,8+jj);

Write('Dati numarul: ',jj,': ');

Textbackground(blue);

gotoxy(54,8+jj);

write(' ');

gotoxy(54,8+jj);

Read(aux);

Until (IOResult=0) and((aux>=0) and(aux<=49));

sir[n].numere[jj]:=aux;

Inc(jj);

Until jj=7;

end;

procedure afisare(i:integer);

var jj:byte;

begin

clrscr;

with sir[i] do

begin

gotoxy(36,4);

write('Informatiile despre biletul ',i,' ');

gotoxy(36,6);

write('Numele si prenumele: ' ,nume,' ');

gotoxy(36,8);

write('Numerele alese: ');

for jj:=1 to 6 do

begin

gotoxy(wherex+2,wherey);

Write(numere[jj]);

end;

readln;

end;

end;

Procedure creare_castigatori;

var jj:byte;

u,o,categorie:byte;

auxx:bilet;

Begin

rewrite(f);

clear_win;

Textbackground(11);

Textcolor(11);

Gotoxy(47,3);

Write( ' Castigatori ');

GoToXY(34,4);

For i:=1 to n do

Begin

clear_win;

categorie:=7;

for jj:=1 to 6 do

begin

if (sir[i].numere[jj]=s[1])or(sir[i].numere[jj]=s[2])or(sir[i].numere[jj]=s[3])or

(sir[i].numere[jj]=s[4])or(sir[i].numere[jj]=s[5])or(sir[i].numere[jj]=s[6]) then

Dec(categorie);

End;

if (categorie=1) or (categorie=2) or (categorie=3) then

begin

auxx.categorie:=categorie;

auxx.cod:=i;

auxx.nume:=sir[i].nume;

o:=1;

repeat

begin

auxx.numere[o]:=sir[i].numere[o];

Inc(o);

End

until o=7 ;

Write(f,auxx);

End;

End;

Close(f);

End;

Procedure afisare_castigatori;

var o:byte;

Begin

Reset(f);

while not eof(f) do

begin

clear_win;

Read(f,a);

GoToXy(34,4);

WriteLn('Categoria:',a.categorie);

GoToXy(34,5);

WriteLn('Numarul biletului:',a.cod);

GoToXy(34,6);

Writeln('Numele si prenumele: ',a.nume);

GoToXy(34,7);

Write('Numerele: ');

for o:=1 to 6 do

begin

GoToXy(44,8+o);

Write(a.numere[o]);

End;

readkey;

End;

Clear_win;

Close(f);

End;

Procedure new_game;

Begin

assign(f,'castig.dat');

Rewrite(f);

Close(f);

erase(f);

Rewrite(f);

Close(f);

n:=0;

End;

Begin

End.





Politica de confidentialitate


creeaza logo.com Copyright © 2024 - Toate drepturile rezervate.
Toate documentele au caracter informativ cu scop educational.