Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 5.21 KB | None | 0 0
  1. program project1;
  2.  
  3. uses
  4. crt, sysutils;
  5.  
  6. var
  7.  myBoard : Array[1..3,1..3] of string;
  8.  response, name1, name2: string;
  9.  textcol: integer;
  10.  
  11.  
  12. function Center(S: String): String;
  13.           var
  14.            i: integer;
  15.           begin
  16.            for i := 1 to (80 - Length(S)) div 2 do
  17.            S := ' ' + S;
  18.           end;
  19.  
  20. procedure cwriteln(S: String);
  21.   begin
  22.    GotoXY((80 - Length(S)) div 2, WhereY);
  23.    WriteLn(S);
  24.   end;
  25. procedure header;
  26.  
  27. begin
  28.  textcolor(textcol);
  29.  cwriteln('  _________         .___      __           ');
  30.  cwriteln(' /   _____/__ __  __| _/____ |  | ____ __  ');
  31.  cwriteln(' \_____  \|  |  \/ __ |/  _ \|  |/ /  |  \ ');
  32.  cwriteln(' /        \  |  / /_/ (  <_> )    <|  |  / ');
  33.  cwriteln('/_______  /____/\____ |\____/|__|_ \____/  ');
  34.  cwriteln('       \/           \/           \/        ');
  35. end;
  36. procedure instructions;
  37. begin
  38.  clrscr;
  39.  header;
  40.   textcolor(textcol);
  41.   cwriteln('The Classic Sudoku is a number placing puzzle based on a 9x9 grid');
  42.   cwriteln('with several given numbers. The object is to place the numbers ');
  43.   cwriteln('1 to 9 in the empty squares so that each row, each column and ');
  44.   cwriteln('each 3x3 box contains the same number only once.');
  45.   writeln;
  46.   writeln;
  47.   cwriteln('Press ''Enter'' to return to the menu');
  48.   readln();
  49.  
  50. end;
  51. procedure credits;
  52.  
  53. begin
  54.  clrscr;
  55.  header;
  56.  writeln;
  57.  writeln;
  58.  cwriteln('This game was brought to you by, Bailey Crouch and Thomas Gayner.');
  59.  cwriteln('Copyright Disclaimer Under Section 107 of the Copyright Act');
  60.  cwriteln('1976, allowance is made for "fair use" for purposes such as criticism,');
  61.  cwriteln('comment, news reporting, teaching, scholarship, and research. Fair');
  62.  cwriteln('use is a use permitted by copyright statute that might otherwise be');
  63.  cwriteln('infringing. Non-profit, educational or personal use tips the balance');
  64.  cwriteln('in favor of fair use.');
  65.  writeln;
  66.  writeln;
  67.  cwriteln('Press ''Enter'' to return to the menu');
  68.  readln();
  69. end;
  70. procedure textcolchange;
  71. begin
  72. ClrScr;
  73. header;
  74. writeln();
  75. cwriteln('Enter the code for the number that you would like to change the text to');
  76. writeln();
  77. cwriteln('1 - Blue              9 - Light Blue               ');
  78. cwriteln('2 - Green            10 - Light Green              ');
  79. cwriteln('3 - Cyan             11 - Light Cyan               ');
  80. cwriteln('4 - Red              12 - Light Red                ');
  81. cwriteln('5 - Magenta          13 - Light Magenta            ');
  82. cwriteln('6 - Brown            14 - Yellow                   ');
  83. cwriteln('7 - White            15 - High-Intensity White     ');
  84. cwriteln('8 - Grey                                           ');
  85.  
  86. readln(textcol);
  87.  
  88. TextColor(textcol);
  89.  
  90. end;
  91.  
  92. Procedure menu;
  93.  
  94.           begin
  95.            response:='m';
  96.  
  97.             while (response <>  'P') do
  98.             begin
  99.             ClrScr;
  100.             header;
  101.             writeln();
  102.             cwriteln('Welocome to the Sudoku game!');
  103.             cwriteln('----------------------------');
  104.             CWriteLn('(P) Play Game              ');
  105.             CWriteLn('(R) Rules                  ');
  106.             CWriteln('(A) Acknowledgements       ');
  107.             CWriteln('(T) Text Appearance        ');
  108.  
  109.             response:= readkey;
  110.  
  111.             case response of
  112.  
  113.             'R' : instructions;
  114.             'r' : instructions;
  115.             'A' : credits;
  116.             'a' : credits;
  117.             'T' : textcolchange;
  118.             't' : textcolchange;
  119.             'p' : response:='P';
  120.  
  121.  
  122.  
  123.             end;//case
  124.             end;
  125.             end;
  126. procedure drawboard;
  127.  
  128. begin
  129. write(myBoard[1,1]); write('__');
  130. write(myBoard[1,2]); write('__');
  131. write(myBoard[1,3]); write('__');
  132. write(myBoard[1,4]); write('__');
  133. write(myBoard[1,5]); write('__');
  134. write(myBoard[1,6]); write('__');
  135. write(myBoard[1,7]); write('__');
  136. write(myBoard[1,8]); write('__');
  137. writeln(myBoard[1,9]);
  138.                       write(myBoard[2,1]); write('__');
  139.                       write(myBoard[2,2]); write('__');
  140.                       write(myBoard[2,3]); write('__');
  141.                       write(myBoard[2,4]); write('__');
  142.                       write(myBoard[2,5]); write('__');
  143.                       write(myBoard[2,6]); write('__');
  144.                       write(myBoard[2,7]); write('__');
  145.                       write(myBoard[2,8]); write('__');
  146.                       writeln(myBoard[2,9]);
  147. write(myBoard[3,1]); write('__');
  148. write(myBoard[3,2]); write('__');
  149. write(myBoard[3,3]); write('__');
  150. write(myBoard[3,4]); write('__');
  151. write(myBoard[3,5]); write('__');
  152. write(myBoard[3,6]); write('__');
  153. write(myBoard[3,7]); write('__');
  154. write(myBoard[3,8]); write('__');
  155. writeln(myBoard[3,9]);
  156.  
  157. end;
  158. begin
  159.   textcol:=(1);
  160.   menu;
  161.   clrscr;
  162.   header;
  163.  
  164.   writeln('Welcome to Sudoku!');
  165.   writeln;
  166.   writeln;
  167.   writeln('You are Player 1, please enter your name');
  168.   readln(name1);
  169.   writeln('Welcome, ', name1);
  170.   readln();
  171.   clrscr;
  172.   header;
  173.   writeln('You are Player 2, please enter your name');
  174.   readln(name2);
  175.   writeln('Welcome, ', name2);
  176.   readln();
  177.   clrscr;
  178.   header;
  179.   writeln(name1, '''s turn is first, please enter a number between 1 and 9 in the row of your reference');
  180.   readln();
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement