|
| Kommentar Fra : Balcanard |
Dato : 23-04-15 23:25 |
| | |
| Kommentar Fra : molokyle |
Dato : 23-04-15 23:31 |
|
Jeg skrev engang et sådant program: "Bordplan" i Turbo Pascal til DOS platformen.
Kode Unit Udform;
Interface
Uses
BordDeff;
Procedure Initier_Bordplan;
Procedure Opstil_Bordplan;
Procedure Vis_Bordplan;
Procedure Ret_Bordplan;
Procedure Start_Bordplan;
Procedure Udskriv_Bordplan;
Procedure Slet_Bordplan;
Procedure Afslut_Bordplan;
Implementation
Uses
Crt,Printer;
Const
TOP = 1;
NEDERST = 25;
LINIE = 80;
NY_SIDE = #12;
_TIlBAGE = #8;
_RETUR = #13;
_ESC = #27;
_MELLEMRUM = #32;
_HOME = #71;
_PILOP = #72;
_PILVENSTRE = #75;
_PILHOEJRE = #77;
_END =#79;
_PILNED = #80;
_INSERT = #82;
_DELETE = #83;
Var
Ok:Boolean;
Position:Base;
Overskrift:String;
Bord:Array [1..BORDMAX] of Borde;
StolePrBord:Array [1..BORDMAX] of Byte;
BordPosition:Array [1..BORDMAX] of Base;
Antal_M_Stole,Antal_K_Stole,Antal_Borde:Integer;
Function Indtast:String;
Var
Tal:Byte;
Tegn:Char;
Saetning:String;
Begin
Ok:=Nej;
Tal:=0;
Tegn:=#0;
Saetning:='';
Repeat
Tegn:=ReadKey;
If Tegn In ['a'..'z','A'..'Z','‘','›','†','’','','','0'..'9',
'"','%','&','/','!','?','.',',',';',':',' ','*','-','+'] Then
Begin
Write(Tegn);
Inc(Tal);
Insert(Tegn,Saetning,Tal);
Tegn:=#0;
End;
If (Tegn = _TILBAGE) And (Tal > 0) Then
Begin
Write(_TILBAGE);
Write(' ');
Write(_TILBAGE);
Delete(Saetning,Tal,1);
Dec(Tal);
End;
If Tegn = _RETUR Then
Ok:=Ja;
Until Ok;
Indtast:=Saetning;
End;
Function Int2Str(Tal:LongInt):String;
Var
Saetning:String;
Begin
Str(Tal,Saetning);
Int2Str:=Saetning;
End;
Function Str2Int(Saetning:String):Integer;
Var
Tal,Kode:Integer;
Begin
Val(Saetning,Tal,Kode);
If Kode <> 0 Then
Str2Int:=-1
Else
Str2Int:=Tal;
End;
Function Centrer(Saetning:String):Byte;
Var
Laengde:Byte;
Begin
Laengde:=Length(Saetning);
If Laengde <= LINIE Then
Centrer:=(LINIE-Laengde) Shr 1
Else
Centrer:=1;
End;
Procedure Statuslinie;
Begin
TextColor(MENUTEKST);
TextBackground(MENUBAGGRUND);
Gotoxy(1,NEDERST);
ClrEol;
TextColor(TEKST);
TextBackground(BAGGRUND);
End;
Function Fejl(Fejltekst:String):Boolean;
Var
Tast:Char;
Begin
TextColor(BLINKTEKST);
TextBackGround(BLINKBAGGRUND);
Gotoxy(1,NEDERST);
ClrEol;
Gotoxy(Centrer(FejlTekst),NEDERST);
Write(Fejltekst);
Repeat
Tast:=ReadKey;
Until Tast = _MELLEMRUM;
StatusLinie;
Fejl:=False;
End;
Procedure CopyRight;
Var
info:String[LINIE];
Begin
info:='Bordplan V1.0 CopyRight Henrik Mortensen 1995.';
TextColor(MENUTEKST);
TextBackground(MENUBAGGRUND);
Gotoxy(1,TOP);
Clreol;
Gotoxy(Centrer(info),TOP);
Writeln(info);
TextColor(TEKST);
TextBackground(BAGGRUND);
End;
Procedure Initier_Bordplan;
Var
bnr:Byte;
Tal:String;
Begin
bnr:=0;
Antal_Borde:=0;
TextColor(TEKST);
TextBackground(BAGGRUND);
Clrscr;
CopyRight;
Statuslinie;
Repeat
Ok:=Ja;
Gotoxy(2,4);
Write('Overskrift : ');
ClrEol;
Gotoxy(16,4);
Overskrift:=Indtast;
If Length(Overskrift) = 0 Then
Ok:=Fejl('Der skal angives en overskrift ! Tryk p† [ MELLEMRUM ] for at forts‘tte...');
If Length(Overskrift) > LINIE Then
Ok:=Fejl('H›jst '+Int2Str(LINIE)+' bogstaver ! Tryk p† [ MELLEMRUM ] for at forts‘tte...');
Until Ok;
Repeat
Ok:=Ja;
Gotoxy(2,6);
Write('Hvor mange borde skal indg† i bordplanen ?');
ClrEol;
Gotoxy(45,6);
Tal:=Indtast;
Antal_Borde:=Str2Int(Tal);
If Antal_Borde = -1 Then
Begin
Antal_Borde:=1;
Ok:=Fejl('Der kan kun indtastes tal ! Tryk p† [ MELLEMRUM ] for at forts‘tte...');
End;
If Antal_Borde > BORDMAX Then
Begin
Antal_Borde:=1;
Ok:=Fejl('H›jst '+Int2Str(BORDMAX)+' borde ! Tryk p† [ MELLEMRUM ] for at forts‘tte...');
End;
If Antal_Borde < BORDMIN Then
Begin
Antal_Borde:=1;
Ok:=Fejl('Der skal mindst v‘re '+Int2Str(BORDMIN)+' bord ! Tryk p† [ MELLEMRUM ] for at forts‘tte...');
End;
Until Ok;
Repeat
Inc(bnr);
Gotoxy(2,8);
Write('Hvor mange stole skal der v‘re ved bord nummer ',bnr,' ?');
ClrEol;
Gotoxy(53,8);
Tal:=Indtast;
StolePrBord[bnr]:=Str2Int(Tal);
If Str2Int(Tal) = -1 Then
Begin
StolePrBord[bnr]:=STOLMIN;
Ok:=Fejl('Der kan kun indtastes tal ! Tryk p† [ MELLEMRUM ] for at forts‘tte...');
End;
If StolePrBord[bnr] > STOLMAX Then
Begin
StolePrBord[bnr]:=STOLMIN;
Ok:=Fejl('H›jst '+Int2Str(STOLMAX)+' stole ! Tryk p† [ MELLEMRUM ] for at forts‘tte...');
End;
If StolePrBord[bnr] < STOLMIN Then
Begin
StolePrBord[bnr]:=STOLMIN;
Ok:=Fejl('Mindst '+Int2Str(STOLMIN)+' stole pr. bord ! Tryk p† [ MELLEMRUM ] for at forts‘tte...');
End;
If Ok = Nej Then
Begin
Dec(bnr);
Ok:=Ja;
End;
Until bnr = Antal_Borde;
End;
Function Test_Plads(bnr:Byte):Boolean;
Var
Bordet,BordLaengde,NaesteBordLaengde:Byte;
Begin
Dec(bnr);
If bnr >= 1 Then
Begin
For Bordet:=1 To bnr Do
Begin
BordLaengde:=StolePrBord[Bordet] Shl 1;
NaesteBordLaengde:=StolePrBord[bnr+1] Shl 1;
If (((Position^.x >= BordPosition[Bordet]^.x)
And
(Position^.x <= BordPosition[Bordet]^.x+BordLaengde))
Or
((Position^.x+NaesteBordLaengde >= BordPosition[Bordet]^.x)
And
(Position^.x+NaesteBordLaengde <= BordPosition[Bordet]^.x+BordLaengde))
Or
((Position^.x <= BordPosition[Bordet]^.x)
And
(Position^.x+NaesteBordLaengde >= BordPosition[Bordet]^.x+BordLaengde)))
And
((Position^.y >= Bordposition[Bordet]^.y-5)
And
(Position^.y <= BordPosition[Bordet]^.y+5))
Then
Test_Plads:=Nej;
End;
End
Else
Test_Plads:=Ja;
End;
Procedure Tegn_Bord(x,y,bnr:Byte;Synlig:Boolean);
Var
SideLaengde,BordLaengde:Byte;
Begin
BordLaengde:=StolePrBord[bnr] Shl 1;
If Synlig = Ja Then
Begin
Gotoxy(x,y-2);
Write(#201);
Gotoxy(x,y+4);
Write(#200);
Gotoxy(x+BordLaengde,y-2);
Write(#187);
Gotoxy(x+BordLaengde,y+4);
Write(#188);
For SideLaengde:=x+1 To x+BordLaengde-1 Do
Begin
Gotoxy(SideLaengde,y-2);
Write(#205);
Gotoxy(Sidelaengde,y+4);
Write(#205);
End;
For SideLaengde:=0 To 4 Do
Begin
Gotoxy(x,(y-1)+SideLaengde);
Write(#186);
Gotoxy(x+BordLaengde,(y-1)+SideLaengde);
Write(#186);
End;
End
Else
Begin
Gotoxy(x,y-2);
Write(' ');
Gotoxy(x,y+4);
Write(' ');
Gotoxy(x+BordLaengde,y-2);
Write(' ');
Gotoxy(x+BordLaengde,y+4);
Write(' ');
For SideLaengde:=x+1 to x+BordLaengde-1 Do
Begin
Gotoxy(SideLaengde,y-2);
Write(' ');
Gotoxy(SideLaengde,y+4);
Write(' ');
End;
For SideLaengde:=0 To 4 Do
Begin
Gotoxy(x,(y-1)+SideLaengde);
Write(' ');
Gotoxy(x+BordLaengde,(y-1)+SideLaengde);
Write(' ');
End;
End;
End;
Procedure Flyt(b:Byte);
Var
Tast:Char;
info:String[LINIE];
Begin
info:='| '+Chr(24)+' '+Chr(25)+' '+Chr(27)+' '+Chr(26)+' : Flyt | [ENTER] : Plac‚r |';
Ok:=Nej;
Repeat
Repeat
Tast:=ReadKey;
If Tast=#0 Then
Begin
Tast:=Readkey;
Case Tast Of
_PILVENSTRE:Begin
Tegn_Bord(Position^.x,Position^.y,b,Nej);
If Position^.x > 3 Then Dec(Position^.x);
End;
_PILHOEJRE:Begin
Tegn_Bord(Position^.x,Position^.y,b,Nej);
If Position^.x < LINIE-(StolePrBord[b] Shl 1)-1 Then Inc(Position^.x);
End;
_PILOP:Begin
Tegn_Bord(Position^.x,Position^.y,b,Nej);
If Position^.y > 4 Then Dec(Position^.y);
End;
_PILNED:Begin
Tegn_Bord(Position^.x,Position^.y,b,Nej);
If Position^.y < NEDERST-5 Then Inc(Position^.y);
End;
End;
End;
Tegn_Bord(Position^.x,Position^.y,b,Ja);
Until Tast=_RETUR;
Ok:=Test_Plads(b);
If Not Ok Then
Begin
Ok:=Fejl('Bordene overlapper hinanden ! Tryk p† [ MELLEMRUM ] for at forts‘tte...');
Gotoxy(Centrer(info),NEDERST);
Write(info);
End;
Until Ok;
End;
Procedure Opstil_Bordplan;
Var
bnr:Byte;
info:String[LINIE];
Begin
bnr:=0;
info:='| '+Chr(24)+' '+Chr(25)+' '+Chr(27)+' '+Chr(26)+' : Flyt | [ENTER] : Plac‚r |';
ClrScr;
CopyRight;
TextColor(MENUTEKST);
TextBackground(MENUBAGGRUND);
Gotoxy(1,NEDERST);
ClrEol;
Gotoxy(Centrer(info),NEDERST);
Write(info);
TextColor(TEKST);
TextBackground(BAGGRUND);
Repeat
Inc(bnr);
New(Position,Init(3,4,0));
Tegn_Bord(Position^.x,Position^.y,bnr,Ja);
Flyt(bnr);
New(Bordposition[bnr],Init(Position^.x,Position^.y,bnr));
Dispose(Position);
Until bnr = Antal_Borde;
End;
Procedure Vis_Bordplan;
Var
Tast:Char;
snr,bnr:Byte;
info:String[LINIE];
Begin
Antal_M_Stole:=0;
Antal_K_Stole:=0;
ClrScr;
Statuslinie;
Gotoxy(1,1);
TextColor(MENUTEKST);
TextBackground(MENUBAGGRUND);
ClrEol;
Gotoxy(((LINIE-Length(Overskrift)) Shr 1),TOP);
Write(Overskrift);
For bnr:=1 To Antal_Borde Do
Begin
New(Bord[bnr],Init(BordPosition[bnr]^.x,BordPosition[bnr]^.y,
BordPosition[bnr]^.Nummer,StolePrBord[bnr]));
Dispose(BordPosition[bnr]);
For snr:=1 To Bord[bnr]^.Pladser Do
If Bord[bnr]^.Stol[snr]^.MK = Mand Then
Inc(Antal_M_Stole)
Else
Inc(Antal_K_Stole);
End;
TextColor(MENUTEKST);
TextBackground(MENUBAGGRUND);
info:=(' Der er '+Int2Str(Antal_Borde)+' borde med plads til '
+Int2Str(Antal_M_Stole+Antal_K_Stole)+' g‘ster, heraf '
+Int2Str(Antal_M_Stole)+' m‘nd og '+Int2Str(Antal_K_Stole)+' kvinder.');
Gotoxy(Centrer(info),NEDERST);
Write(info);
ClrEol;
Repeat
Tast:=ReadKey;
Until Tast <> #255;
End;
Procedure Vis_Status;
Var
bnr,snr:Byte;
info:String[LINIE];
Begin
Antal_M_Stole:=0;
Antal_K_Stole:=0;
For bnr:=1 To Antal_Borde Do
Begin
For snr:=1 To Bord[bnr]^.Pladser Do
Begin
If Bord[bnr]^.Stol[snr]^.MK = Mand Then
Inc(Antal_M_Stole)
Else
Inc(Antal_K_Stole);
End;
End;
TextColor(MENUTEKST);
TextBackground(MENUBAGGRUND);
info:=(' Der er '+Int2Str(Antal_Borde)+' borde med plads til '
+Int2Str(Antal_M_Stole+Antal_K_Stole)+' g‘ster, heraf '
+Int2Str(Antal_M_Stole)+' m‘nd og '+Int2Str(Antal_K_Stole)+' kvinder.');
Gotoxy(Centrer(info),TOP);
Write(info);
ClrEol;
End;
Procedure RetBord(bnr:Byte);
Var
Tast:Char;
snr:Byte;
info:String[LINIE];
Begin
snr:=1;
info:='| END Nyt Bord | HOME Vend | DELETE Skift stol | INSERT Ombyt | ESC Afslut |';
Gotoxy(Bord[bnr]^.x+1,Bord[bnr]^.y+1);
TextColor(BLINKTEKST);
TextBackground(BORDFARVE);
Write('Bord ',Bord[bnr]^.Nummer);
If Bord[bnr]^.Stol[snr]^.MK = Mand Then
TextBackground(M_FARVE)
Else
TextBackground(K_FARVE);
Bord[bnr]^.Stol[snr]^.Oplys;
Repeat
Tast:=ReadKey;
If Tast=#0 Then
Begin
Tast:=Readkey;
Case Tast Of
_HOME:Begin
If Bord[bnr]^.y > NEDERST-Bord[bnr]^.Pladser-1 Then
Begin
Ok:=Fejl('Bordet er for langt til at vendes ! Tryk p† [ MELLEMRUM ] for at fors‘tte...');
Gotoxy(Centrer(info),NEDERST);
TextColor(MENUTEKST);
TextBackground(MENUBAGGRUND);
Write(info);
ClrEol;
End
Else
Begin
Bord[bnr]^.Skjul;
Bord[bnr]^.Vend;
Bord[bnr]^.Vis;
If Bord[bnr]^.Stol[snr]^.MK = Mand Then
TextBackground(M_FARVE)
Else
TextBackground(K_FARVE);
Bord[bnr]^.Stol[snr]^.Oplys;
TextColor(BLINKTEKST);
TextBackground(BORDFARVE);
Gotoxy(Bord[bnr]^.x+1,Bord[bnr]^.y+1);
Write('Bord ',Bord[bnr]^.Nummer);
End;
End;
_END:Begin
snr:=1;
Bord[bnr]^.Skjul;
Bord[bnr]^.Vis;
If bnr = Antal_Borde Then
bnr:=1
Else
Inc(bnr);
If Bord[bnr]^.Stol[snr]^.MK = Mand Then
TextBackground(M_FARVE)
Else
TextBackground(K_FARVE);
Bord[bnr]^.Stol[snr]^.Oplys;
TextColor(BLINKTEKST);
TextBackground(BORDFARVE);
Gotoxy(Bord[bnr]^.x+1,Bord[bnr]^.y+1);
Write('Bord ',Bord[bnr]^.Nummer);
End;
_INSERT:Begin
Bord[bnr]^.Stol[snr]^.Ret;
Bord[bnr]^.Stol[snr]^.Oplys;
Vis_Status;
End;
_DELETE:Begin
Bord[bnr]^.Stol[snr]^.Vis;
If Bord[bnr]^.Stol[snr]^.Nummer = Bord[bnr]^.Pladser Then
snr:=1
Else
Inc(snr);
If Bord[bnr]^.Stol[snr]^.MK = Mand Then
TextBackground(M_FARVE)
Else
TextBackground(K_FARVE);
Bord[bnr]^.Stol[snr]^.Oplys;
End;
End;
End;
Until Tast=_ESC;
End;
Procedure Ret_Bordplan;
Var
Valg:Char;
bnr:Byte;
info:String[LINIE];
Begin
info:='Vil du lave ‘ndringer i bordplanen ? [j/n]';
TextColor(MENUTEKST);
TextBackground(MENUBAGGRUND);
Gotoxy(1,NEDERST);
ClrEol;
Gotoxy(Centrer(info),NEDERST);
Write(info);
Repeat
Valg:=ReadKey;
Until Valg In ['j','J','n','N'];
If (Valg='j') Or (Valg='J') Then
Begin
info:='| END Nyt Bord | HOME Vend | DELETE Skift stol | INSERT Ombyt | ESC Afslut |';
Gotoxy(1,NEDERST);
ClrEol;
Gotoxy(Centrer(info),NEDERST);
Write(info);
RetBord(Antal_Borde);
End;
Gotoxy(1,NEDERST);
ClrEol;
For bnr:=1 To Antal_Borde Do
Bord[bnr]^.Vis;
End;
Procedure Udskriv(bnr,snr:Byte;nvn:String);
Begin
While Length(Overskrift) < (LINIE Shr 1)+1 Do
Insert(' ',Overskrift,1);
WriteLn(Lst,Overskrift);
WriteLn(Lst,'');WriteLn(Lst,'');
WriteLn(Lst,' Velkommen '+nvn+'.');
WriteLn(Lst,'');WriteLn(Lst,'');
WriteLn(Lst,' Du har f†et plads ved bord '+Int2Str(bnr)+
' p† stol nummer '+Int2Str(snr)+'.');
WriteLn(Lst,'');WriteLn(Lst,'');
WriteLn(Lst,' H†ber du finder dig godt til rette ved bordet.');
WriteLn(Lst,NY_SIDE);
End;
Procedure Start_Bordplan;
Var
Valg:Char;
bnr,snr,Stolene:Byte;
Mandestole,Kvindestole:Integer;
info,Navn:String[LINIE];
Label NONAME;
Begin
Mandestole:=Antal_M_Stole;
Kvindestole:=Antal_K_Stole;
Stolene:=0;
TextColor(MENUTEKST);
TextBackground(MENUBAGGRUND);
Gotoxy(1,TOP);
ClrEol;
Gotoxy(Centrer(Overskrift),TOP);
Write(Overskrift);
Repeat
NONAME:
info:=' Velkommen k‘re g‘st, hvad er dit navn ...? : ';
Gotoxy(1,NEDERST);
Write(info);
ClrEol;
Gotoxy(48,NEDERST);
Navn:=Indtast;
If Pos(' ',Navn) = 1 Then
Delete(Navn,1,1);
If Length(Navn) < 2 Then
Goto NONAME;
Gotoxy(1,NEDERST);
ClrEol;
info:=' '+Navn+' er du mand eller kvinde ? [m/k]';
Gotoxy(Centrer(info),NEDERST);
Write(info);
ClrEol;
Repeat
Valg:=ReadKey;
Until Valg In ['m','M','k','K'];
If Valg In ['m','M'] Then
Dec(Mandestole)
Else
If Valg In ['k','K'] Then
Dec(Kvindestole);
If (Mandestole < 0) Then
Begin
Ok:=Fejl('Der er ikke plads til flere m‘nd, du m† tage en kvindes plads !');
Valg:='k';
Mandestole:=0;
Dec(Kvindestole);
End;
If (Kvindestole < 0) Then
Begin
Ok:=Fejl('Der er ikke plads til flere kvinder, du m† tage en mands plads !');
Valg:='m';
Kvindestole:=0;
Dec(Mandestole);
End;
TextColor(MENUTEKST);
TextBackground(MENUBAGGRUND);
Gotoxy(1,NEDERST);
ClrEol;
info:=' '+Navn+' tryk p† en tast og find din plads !';
Gotoxy(Centrer(info),NEDERST);
Write(info);
ClrEol;
Randomize;
Repeat
Ok:=False;
bnr:=Random(Antal_Borde)+1;
snr:=Random(Bord[bnr]^.Pladser)+1;
If (Bord[bnr]^.Stol[snr]^.Optaget = Nej) Then
Begin
If ((Bord[bnr]^.Stol[snr]^.MK = Mand) And (Valg In ['m','M'])) Or
((Bord[bnr]^.Stol[snr]^.MK = Not Mand) And (Valg In ['k','K'])) Then
Begin
Delay(Random(1000));
Bord[bnr]^.Stol[snr]^.Oplys;
Sound(Random(1000));
Delay(100);
NoSound;
Bord[bnr]^.Stol[snr]^.Vis;
If Keypressed Then
Ok:=True;
End
End;
Until Ok;
Bord[bnr]^.Stol[snr]^.Valgt(Navn);
Bord[bnr]^.Stol[snr]^.Vis;
TextColor(MENUTEKST);
TextBackground(MENUBAGGRUND);
Gotoxy(1,NEDERST);
ClrEol;
Udskriv(bnr,snr,Navn);
Inc(Stolene);
Until Stolene = Antal_M_Stole+Antal_K_Stole;
End;
Procedure Udskriv_Bordplan;
Var
bnr,snr:Byte;
Begin
WriteLn(Lst,' - Bordplan.exe V 1.0 - CopyRight Henrik Mortensen 1995. -');
WriteLn(Lst,'');WriteLn(Lst,'');WriteLn(Lst,'');
WriteLn(Lst,Overskrift);
WriteLn(Lst,'');WriteLn(Lst,'');
For bnr:=1 To Antal_Borde Do
Begin
WriteLn(Lst,'');WriteLn(Lst,'');
WriteLn(Lst,' G‘ster ved Bord ',bnr,' :');
WriteLn(Lst,'');
For snr:=1 to Bord[bnr]^.Pladser-1 Do
Begin
WriteLn(Lst,' '+Bord[bnr]^.Stol[snr]^.Navn+' sidder p† stol nummer : ',snr,'.');
End;
End;
End;
Procedure Slet_BordPlan;
Var
bnr:Byte;
Begin
For bnr:=1 To Antal_Borde Do
Begin
Dispose(Bord[bnr]);
End;
End;
Procedure Afslut_Bordplan;
CONST
MIDT = 5;
VAR
info:String[LINIE];
tegn,stop:Char;
antal:Byte;
Begin
info:=' - Tak, fordi du brugte : Bordplan V1.0';
ClrScr;
CopyRight;
Gotoxy(1,NEDERST);
Write(' ESC = Afslut.');
ClrEol;
Window(10,8,70,16);
ClrScr;
Repeat
Gotoxy((60 DIV 2)-(Length(info) DIV 2),5);
Write(info);
ClrEol;
tegn:=info[1];
for antal:=2 To Length(info) Do
Begin
info[antal-1]:=info[antal];
End;
info[Length(info)]:=tegn;
Delay(120);
If KeyPressed Then
stop:=ReadKey;
Until stop = _ESC;
Window(1,1,80,25);
TextColor(DOSTEKST);
TextBackground(DOSBAGGRUND);
ClrScr;
End;
Begin
End.
Unit BordDeff;
Interface
Uses
Crt;
Const
NORD_SYD = True;
OST_VEST = False;
Ja = True;
Nej = False;
Mand = True;
STOLMAX = 18;
STOLMIN = 4;
BORDMAX = 6;
BORDMIN = 1;
BORDFARVE = Brown;
BORDSKYGGE = Black;
STOLFARVE = Green;
M_FARVE = Blue;
K_FARVE = Red;
TEKST = Yellow;
BAGGRUND = Green;
MENUTEKST = Black;
MENUBAGGRUND = LightGray;
BLINKTEKST = Yellow+Blink;
BLINKBAGGRUND = Red;
DOSTEKST=LightGray;
DOSBAGGRUND=Black;
FRI_STOL = #1;
OPTAGET_STOL = #2;
BLANK = #32;
OST_VEST_SKYGGE = #219;
SKYGGEHJOERNE =#220;
NORD_SYD_SKYGGE = #223;
Type
Base = ^BaseType;
Stole = ^Stoltype;
Borde = ^Bordtype;
Basetype = Object
x,y,Nummer:Byte;
Constructor Init(a,b,nr:Byte);
End;
StolType = Object(BaseType)
Optaget:Boolean;
MK:Boolean;
Navn:String;
Procedure Ret;
Procedure Valgt(nvn:String);
Procedure Oplys;
Procedure Vis;
Constructor Init(a,b,snr:Byte;Person:Boolean);
End;
BordType = Object(BaseType)
Orientering:Boolean;
Pladser,Laengde,Side:Byte;
Stol:Array [1..STOLMAX] of Stole;
Procedure Vend;
Procedure Vis;
Procedure Skjul;
Constructor Init(a,b,bnr,Antal:Byte);
Destructor Ryd;
End;
Implementation
Constructor BaseType.Init(a,b,nr:Byte);
Begin
x:=a;
y:=b;
Nummer:=nr;
End;
Constructor StolType.Init(a,b,snr:Byte;Person:Boolean);
Begin
BaseType.Init(a,b,snr);
Optaget:=Nej;
MK:=Person;
Navn:='';
End;
Procedure StolType.Ret;
Begin
MK:=Not MK;
End;
Procedure StolType.Valgt(nvn:String);
Begin
Optaget:=Ja;
Navn:=nvn;
End;
Procedure Stoltype.Oplys;
Begin
TextColor(BLINKTEKST);
If MK = Mand Then
TextBackground(M_FARVE)
Else
TextBackground(K_FARVE);
Gotoxy(x,y);
Write(OPTAGET_STOL);
TextColor(TEKST);
TextBackground(BAGGRUND);
End;
Procedure StolType.Vis;
Begin
TextBackground(STOLFARVE);
If MK = Mand Then
TextColor(M_FARVE)
Else
TextColor(K_FARVE);
Gotoxy(x,y);
If Optaget Then
Write(OPTAGET_STOL)
Else
Write(FRI_STOL);
TextColor(TEKST);
TextBackground(BAGGRUND);
End;
Constructor BordType.Init(a,b,bnr,Antal:Byte);
Var
i,j,snr:Byte;
mkt:Boolean;
Begin
BaseType.Init(a,b,bnr);
Orientering:=OST_VEST;
Pladser:=Antal;
Laengde:=Antal Shl 1;
Side:=Antal Shr 1;
mkt:=Mand;
i:=x+2;
Begin
For snr:=1 To Pladser Do
Begin
If snr <= Side Then
j:=y-1
Else
j:=y+4;
New(Stol[snr],Init(i,j,snr,mkt));
mkt:=Not mkt;
i:=i+4;
If (i > x+Laengde-1) And (j = y-1) Then
i:=x+2;
End;
End;
Vis;
End;
Destructor BordType.Ryd;
Var
snr:Byte;
Begin
For snr:=1 To Pladser Do
Dispose(Stol[snr]);
End;
Procedure BordType.Vend;
Var
Siden,snr:Byte;
Begin
Orientering:=Not Orientering;
If Orientering = NORD_SYD Then
Begin
Siden:=y;
For snr:=1 To Pladser Do
Begin
If snr <= Side Then
Stol[snr]^.x:=x-2
Else
Stol[snr]^.x:=x+8;
Stol[snr]^.y:=Siden;
Siden:=Siden+2;
If (Siden > y+Pladser-2) And (Stol[snr]^.x = x-2) Then
Siden:=y;
End;
End
Else
Begin
Siden:=x+2;
For snr:=1 To Pladser Do
Begin
If snr <= Side Then
Stol[snr]^.y:=y-1
Else
Stol[snr]^.y:=y+4;
Stol[snr]^.x:=Siden;
Siden:=Siden+4;
If (Siden > x+Laengde-1) And (Stol[snr]^.y = y-1) Then
Siden:=x+2;
End;
End;
End;
Procedure BordType.Skjul;
Var
a,b:Byte;
Begin
TextColor(TEKST);
TextBackground(BAGGRUND);
If Orientering = OST_VEST Then
Begin
For a:=x To x+Laengde Do
Begin
For b:=y-1 To y+4 Do
Begin
Gotoxy(a,b);
Write(BLANK);
End;
End;
End
Else
Begin
For a:=x-2 To x+8 Do
Begin
For b:=y To y+Pladser Do
Begin
Gotoxy(a,b);
Write(BLANK);
End;
End;
End;
End;
Procedure BordType.Vis;
Var
a,b,snr:Byte;
Begin
TextColor(BORDFARVE);
TextBackground(BAGGRUND);
Gotoxy(x,y);
If Orientering = OST_VEST Then
Begin
For a:=x To x+Laengde-1 Do
Begin
For b:= 0 To 2 Do
Begin
Gotoxy(a,y+b);
Write(OST_VEST_SKYGGE);
End;
End;
TextColor(BORDSKYGGE);
Gotoxy(x+Laengde,y);
Write(SKYGGEHJOERNE);
For b:=1 To 2 Do
Begin
Gotoxy(x+Laengde,y+b);
Write(OST_VEST_SKYGGE);
End;
For a:=x+1 To x+Laengde Do
Begin
Gotoxy(a,y+3);
Write(NORD_SYD_SKYGGE);
End;
End
Else
Begin
For b:=y To y+Pladser-2 Do
Begin
For a:=0 To 6 Do
Begin
Gotoxy(x+a,b);
Write(OST_VEST_SKYGGE);
End;
End;
TextColor(BORDSKYGGE);
For a:=1 to 7 Do
Begin
Gotoxy(x+a,y+Pladser-1);
Write(NORD_SYD_SKYGGE);
End;
For b:=y+1 To y+Pladser-2 Do
Begin
Gotoxy(x+7,b);
Write(OST_VEST_SKYGGE);
End;
End;
For snr:= 1 to Pladser Do
Stol[snr]^.Vis;
TextBackground(BORDFARVE);
Gotoxy(x+1,y+1);
Write('Bord ',Nummer);
TextBackground(BAGGRUND);
End;
Begin
End.
Program BordPlan;
Uses
Udform;
Begin
Initier_Bordplan;
Opstil_Bordplan;
Vis_Bordplan;
Ret_Bordplan;
Start_Bordplan;
Slet_Bordplan;
Udskriv_Bordplan;
Afslut_Bordplan;
End. |
Værs'go': Hér er kildekoden
Jeg er ikke klar over om andre har været tossede nok til at bixe en sådan 'sag' sammen, blot fordi man skulle holde en lille fest?
</MOLOKYLE>
| |
| Accepteret svar Fra : mig-selv | Modtaget 100 point Dato : 23-04-15 23:55 |
| | |
| Godkendelse af svar Fra : ingelein |
Dato : 26-04-15 10:00 |
|
Tak for svaret mig-selv.
Det er nu ikke et personplaceringsproblem jeg skal have løst, men mere hvordan jeg skal stille bordene, så mine 15,50 m duge slår til . Papir og blyant metoden vandt.??
Ingelein
| |
| Du har følgende muligheder | |
|
Eftersom du ikke er logget ind i systemet, kan du ikke skrive et indlæg til dette spørgsmål.
Hvis du ikke allerede er registreret, kan du gratis blive medlem, ved at trykke på "Bliv medlem" ude i menuen.
| |
|
|