home *** CD-ROM | disk | FTP | other *** search
- Unit Sunit;
-
- interface
-
- type
- date = record
- month:byte;
- day:byte;
- year:word;
- end;
-
- dayptr = ^day;
- day = record
- price:real;
- thing:integer; {
- 1 to 9999 is stock,
- 0 is player
- -99 is stock market average.
- }
- next:dayptr;
- end;
-
- stock = record
- symbol : string[3];
- shares : integer;
- end;
-
- company = record
- name : string;
- symbol : string[3];
- cash : real;
- stock_price : real;
- end;
- var
- universal_date:date;
- first_one,current:dayptr;
-
- co:array[1..20] of company;
- tmp_month:integer;
- num_co:integer;
- _flash:integer;
- _flash_str:string;
-
-
- procedure flash;
- procedure input_stocks;
- procedure stock_window(x,y:integer);
- procedure earn;
- procedure init;
- procedure init_flash;
- procedure init_stocks;
-
- implementation
- uses crt,menu;
-
- procedure init;
- begin
- clrscr;
- box(2,2,79,24);
- gotoxy(32,10);
- write('Stock Simulation');
-
- gotoxy(27,20); write('press any key to continue');
- clrscr;
- with universal_date do begin
- month:=1;
- day:=1;
- year:=1900;
- end;
- new(first_one);
- current:=first_one;
- end;
-
- procedure input_stocks;
- var
- m:file of company;
- co:company;
- i:integer;
-
- begin
- assign(m,'stock.sym');
- rewrite(m);
-
- for i:=1 to 10 do begin
- with co do begin
- write('Name:');
- readln(name);
- write('Symbol:');
- readln(symbol);
- write('Cash:');
- readln(cash);
- write('Stock Price:');
- readln(stock_price);
- writeln('----------------> Next');
- end;
- write(m,co);
- end;
- close(m);
- end;
-
-
- procedure init_stocks;
- var
- m:file of company;
- begin
- assign(m,'stock.sym');
- reset(m);
-
- num_co:=0;
-
- repeat
- inc(num_co);
- read(m,co[num_co]);
- until eof(m);
- close(m);
- end;
-
- procedure init_flash;
- begin
- _flash:=1;
- _flash_str:='';
- end;
-
- procedure flash;
- var
- tmp_s:string;
- begin
- if length(_flash_str)<70 then begin
- str(co[_flash].stock_price:4:2,tmp_s);
- _flash_str:= _flash_str+
- co[_flash].symbol+
- ' '+tmp_s+' ';
- inc(_flash);
- if _flash>num_co then _flash:=1;
- end;
- delete(_flash_str,1,1);
- gotoxy(1,1);
- write(_flash_str);
- end;
-
- procedure stock_window(x,y:integer);
- var i:integer;
- begin
- gotoxy(x+1,y+1);
- write('Symbol':8,'Price':8,'Cash':20);
- for i:=1 to num_co do begin
- gotoxy(x+1,y+1+i);
- with co[i] do
- write(symbol:8,stock_price:8:3,(cash/1000000):20:3);
- end;
- end;
-
- procedure earn;
- var i:integer;
- begin
- if universal_date.month<>tmp_month then begin
- for i:=1 to num_co do begin
- with co[i] do begin
- cash:=cash+(cash*0.05)
- end;
- end;
- tmp_month:=universal_date.month;
- end;
- end;
- end.