Dear Sir,

Could you please give me some of the ideas of making the hotSeat game in pascal?

The following is the simple mode of my coding:-

Program yeungkt1;

{$APPTYPE CONSOLE}

{
    Who wants to be a millionaire.
    Author:  Chris Yeung
    Version 1
}

uses
  SysUtils,
  OurCrt;

Type
   hotSeat_record=record
   lastname:string[12];
   firstname:string[12];
   phone: string[12];
End;

Var User_Choice:Integer;
  hotSeat_file:file of hotSeat_record;
  hotSeat:array[1..100]of hotSeat_record;
  numberRecords:integer;
  numbers: array[1..10] of integer;
  generate: boolean;


Procedure load;
Var
   count:integer;
begin
    assign(hotSeat_file,'hotSeat.dat');
    reset(hotSeat_file);
    numberRecords:= filesize(hotSeat_file);
  for count:=  1 to numberRecords do
  Begin
    read(hotSeat_file,hotSeat[count]);
  end;
end;

Procedure ContestantsList;

Var
   count:integer;

Begin
  numberRecords:= filesize(hotSeat_file);

  WriteLn;

  for count:=  1 to (filesize(hotSeat_file)) do
  Begin
  WriteLn(hotSeat[count].firstname:12,hotSeat[count].lastname:12,
  hotSeat[count].phone:20);
  sleep(100);
  End;
  readln;
end;

Procedure Generate10finalists;
var
  count,temp:integer;

begin
  writeln('Here are the 10 finalist''s numbers');
  randomize;
  for count:= 1 to 10 do
  begin
    temp:=random(numberRecords)+1;
    while(temp=numbers[1])
    or (temp=numbers[2])
    or (temp=numbers[3])
    or (temp=numbers[4])
    or (temp=numbers[5])
    or (temp=numbers[6])
    or (temp=numbers[7])
    or (temp=numbers [8])
    or (temp=numbers [9])
    or (temp=numbers [10]) do
    begin
      temp:=random(numberRecords)+1;
    end;
    numbers[count]:=temp;
    generate := true;
  end;

  for count := 1 to 10 do
    begin
      writeln;
      writeln('     ***<$$$$$>****  ' ,(numbers[count]), '  ****<$$$$>****');
      writeln;
      sleep(100);
    end;
    writeln('              GOOD LUCK !!!!!!!');
    readln;
    clrscr;
end;





Procedure ShowFinalists;
  var
  count: integer;
  Begin
  if (generate = true)  then
  begin
    WriteLn('3 pressed,finding and listing the finalists...');
    WriteLn;
    for count:=1 to 10 do
    begin
      writeln(hotSeat[numbers[count]].firstname:12,
      hotSeat[numbers[count]].lastname:12, hotSeat[numbers[count]].phone:20);
      writeln;
      sleep(200);
    end
  end
  else
      writeln('Please generate finalist number first!');
    readln;
  End;

Procedure save;
  var
  count: integer;
  Begin
    reset(hotSeat_file);
    for count:=1 to filesize(hotSeat_file) do
      begin
       write(hotSeat_file,hotSeat[count]);
      end;
  end;


Procedure ChangeDetails;
  var
  count: integer;
  firstname,lastname,newphone: string[12];
  name: boolean;


  Begin
    name:=false;

        WriteLn('4 pressed,changing the phone a friend details...');



        WriteLn('Please enter your first name.');
        readln(firstname);
        WriteLn('Please enter your last name.');
        readln(lastname);

        for count:=1 to filesize(hotSeat_file) do
        begin
         if (hotSeat[count].lastname=lastname) and
         (hotSeat[count].firstname=firstname) then
        begin
        writeln('Well. We''ve found your records.');
        writeln('Please enter your new phone number < 03 ###-####>');
        readln(newphone);
        hotSeat[count].phone:=newphone;
        name:=true
        end;
        end;
        if name=false then
        begin
        writeln('Sorry!  We do not have your records from your database.');
        end;
        writeln;
        write('Press <ENTER> to save changes and return to the main menu.');

        save;
        readln;

        end;

Procedure EnrolContestant;
  var   lastname:string[12];
        firstname :string[12];
        phone:string[12];
        count :integer;
        name :boolean;

  Begin
    name:=false;
    writeln('Please enter your first name - if you''re new.');
    readln(firstname);
    writeln('Please enter your last name.');
    readln(lastname);
    writeln('Lastly, please enter your phone number.');
    readln(phone);
    writeln('Please press <ENTER>');
    for count:=1 to filesize(hotSeat_file) do
    begin
    if (hotSeat[count].lastname=lastname) and
    (hotSeat[count].firstname=firstname) then
    begin
        name:=true;
        writeln('You''re a contestant already.');
    end;
    end;
    if (name = false) then
    begin

        numberRecords:= numberRecords+ 1;
        hotSeat[filesize(hotSeat_file)].firstname:=firstname;
        hotSeat[filesize(hotSeat_file)].lastname:=lastname;
        hotSeat[filesize(hotSeat_file)].phone:=phone;


  writeln('Please press <ENTER> to save your details and return to main menu.');

        readln;
        save;

    end;
  end;





Procedure GetOutOfHere;
  Begin
    WriteLn('0 pressed,exiting...');
    Sleep(5000);
    clrscr;
  End;
 Procedure Menu;
Begin

      Writeln('               M E N U');
      WriteLn('Please enter an integer in the range 1...5');
      WriteLn;
      WriteLn('  1 List all the contestants');
      WriteLn('  2 Generate the 10 finalist''s numbers');
      WriteLn('  3 Find and list the finalists');
      WriteLn('  4 Change the phone a friend details');
      WriteLn('  5 Enrol a new contestant');
      WriteLn('  0 Exit');


      Readln(User_Choice);

      Case (User_Choice) of
         1:ContestantsList;
         2:Generate10finalists;
         3:ShowFinalists;
         4:ChangeDetails;
         5:EnrolContestant;
         0:GetOutOfHere;
        end;
end;





begin //main body
Load;
repeat
menu;              {Shows the Menu on the screen}
until User_Choice = 0;  {Allows program user to Exit program}
end.

It's the hotSeat.txt file.

Plese change the following line:

assign(hotSeat_file,'hotSeat.dat');

into assign(hotSeat_file,'hotSeat.txt');

i do not understand the question.... :'( what can we do for you?
your program is working... what is the 'hotseat' game?

Dear Sir,

Sorry, I did not express it very well. Hm... Let me see. After the player select '2 Generate the 10 finalist's numbers. All the 10 persons can have chance to win the great price. For example, like the 'deal and no deal' game. They will be asked some of the question, when the first finalist can answer the questions, then he / she will get $100, $500, $1500, $5000, $10000, $30000, $60000, $150000, ... $1000000. If this person do not get the right answer, then, he will lost the chance and the highest prize $1,000,000 will be lost also. Next, ... until all the question have been asked, then he will get the prize. Maybe $150000.

Dear Sir,

Sorry, I did not express very well. Can you catch my meaning?

Cheers,

make a procedure that write out the questions for the players
add chance to them to select an answer,like
question: .......
answer:a,......
b,......
c,.......
if the answer is good then add points or virtual many to the player

Dear Sir,

May I want to add the new procedure to write out the question after the coding of WriteLn(' 2 Generate the 10 finalist''s numbers'); ??

It makes me crazy.

Cheers,

to add money to the players,you sould write your record as

Type
    hotSeat_record=record
                    lastname:string[12];
                    firstname:string[12];
                    phone: string[12];
                    money:longint;   {to store the player's money!}
                   End;

and cause you want to play with the players,you have to add a new variable as array.You need to fill the 10 finalist into this array!

Var
    User_Choice:Integer;
    hotSeat_file:file of hotSeat_record;
    hotSeat:array[1..100]of hotSeat_record;
    numberRecords:integer;
    numbers: array[1..10] of integer;
    generate: boolean;
    players:array[1..10]of hotseat_record; {to play with them!}

ok,let's keep going...
"the questions and the answers"
my opinion is that you can use a record in the "type section" to store the questions and the answers,like

type
    question = record
                {how many money can the player get
                 if she/he adds right answer}
                dollar:longint;
                quest:string;  {question}
                rightansw:string; {the right answer}
                answ1:string;  {answers}
                answ2:string;
                answ3:string;
               end;

a question procedure,just example

procedure ques(y:question;var pl:hotseat_record);
var user:char;
begin
    y.dollar:=1000;
    y.quest:='How many the price of a good laptop?';  {just example...}
    y.rightansw:='5000$';
    y.answ1:='2000$';
    y.answ2:='5000$';
    y.answ3:='7000$';
    
    {welcome the player}
    writeln('Hi ',pl.firstname);
    
    writeln(y.quest);
    writeln('a: ',y.answ1);
    writeln('b: ',y.answ2);
    writeln('c: ',y.answ3);
    readln(user);
    case (user)of
        'a':begin
                writeln('wrong answer');
                pl.money:=pl.money-y.dollar;
            end;
        'b':begin
                writeln('good answer,you get ',y.dollar,'$');
                pl.money:=pl.money+y.dollar;
            end;
        'c':begin
                writeln('wrong answer');
                pl.money:=pl.money-y.dollar;
            end;
    end;



end;

of course you have to save the players again to store his/her money....

Thank you for your kind help. Let me try it on tonight.

Dear Sir,

Sorry, I did not express it very well. Hm... Let me see. After the player select '2 Generate the 10 finalist's numbers. All the 10 persons can have chance to win the great price. For example, like the 'deal and no deal' game. They will be asked some of the question, when the first finalist can answer the questions, then he / she will get $100, $500, $1500, $5000, $10000, $30000, $60000, $150000, ... $1000000. If this person do not get the right answer, then, he will lost the chance and the highest prize $1,000,000 will be lost also. Next, ... until all the question have been asked, then he will get the prize. Maybe $150000.

Great work .. really informative .. and thanks a lot for sharing ..
website update

Dear Sir,

Could you tell me where I want to code 'a question procedure'? May I want to code it after Procedure ShowFinalists?

Cheers,

Dear Sir,

Can I do in the following way??

Program xxx;

{$APPTYPE CONSOLE}


}

uses
  SysUtils,
  OurCrt;

Type
   hotSeat_record=record
   lastname:string[12];
   firstname:string[12];
   address: string[20];
   money:longint;
End;

Var User_Choice:Integer;
  hotSeat_file:file of hotSeat_record;
  hotSeat:array[1..100]of hotSeat_record;
  numberRecords:integer;
  numbers: array[1..10] of integer;
  generate: boolean;
  players:array[1..10] of hotseat_record;

Procedure load;
Var
   count:integer;
begin
    assign(hotSeat_file,'hotSeat.dat');
    reset(hotSeat_file);
    numberRecords:= filesize(hotSeat_file);
  for count:=  1 to numberRecords do
  Begin
    read(hotSeat_file,hotSeat[count]);
  end;
end;

Procedure ContestantsList;

Var
   count:integer;

Begin
  numberRecords:= filesize(hotSeat_file);

  WriteLn;

  for count:=  1 to (filesize(hotSeat_file)) do
  Begin
  WriteLn(hotSeat[count].firstname:12,hotSeat[count].lastname:12,
  hotSeat[count].address:20);
  sleep(100);
  End;
  readln;
end;

Procedure Generate10finalists;
var
  count,temp:integer;

begin
  writeln('Here are the 10 finalist''s numbers');
  randomize;
  for count:= 1 to 10 do
  begin
    temp:=random(numberRecords)+1;
    while(temp=numbers[1])
    or (temp=numbers[2])
    or (temp=numbers[3])
    or (temp=numbers[4])
    or (temp=numbers[5])
    or (temp=numbers[6])
    or (temp=numbers[7])
    or (temp=numbers [8])
    or (temp=numbers [9])
    or (temp=numbers [10]) do
    begin
      temp:=random(numberRecords)+1;
    end;
    numbers[count]:=temp;
    generate := true;
  end;

  for count := 1 to 10 do
    begin
      writeln;
      writeln('     ***<$$$$$>****  ' ,(numbers[count]), '  ****<$$$$>****');
      writeln;
      sleep(100);
    end;
    writeln('              GOOD LUCK !!!!!!!');
    readln;
    clrscr;
end;

procedure ques(y:question;var pl:hotseat_record);
var user:char;
begin
    y.dollar:=1000;
    y.quest:='How many the price of a good laptop?';  {just example...}
    y.rightansw:='5000$';
    y.answ1:='2000$';
    y.answ2:='5000$';
    y.answ3:='7000$';
    
    {welcome the player}
    writeln('Hi ',pl.firstname);
    
    writeln(y.quest);
    writeln('a: ',y.answ1);
    writeln('b: ',y.answ2);
    writeln('c: ',y.answ3);
    readln(user);
    case (user)of
        'a':begin
                writeln('wrong answer');
                pl.money:=pl.money-y.dollar;
            end;
        'b':begin
                writeln('good answer,you get ',y.dollar,'$');
                pl.money:=pl.money+y.dollar;
            end;
        'c':begin
                writeln('wrong answer');
                pl.money:=pl.money-y.dollar;
            end;
    end;



end;



Procedure ShowFinalists;
  var
  count: integer;
  Begin
  if (generate = true)  then
  begin
    WriteLn('3 pressed,finding and listing the finalists...');
    WriteLn;
    for count:=1 to 10 do
    begin
      writeln(hotSeat[numbers[count]].firstname:12,
      hotSeat[numbers[count]].lastname:12, hotSeat[numbers[count]].address:20);
      writeln;
      sleep(200);
    end
  end
  else
      writeln('Please generate finalist number first!');
    readln;
  End;

Procedure save;
  var
  count: integer;
  Begin
    reset(hotSeat_file);
    for count:=1 to filesize(hotSeat_file) do
      begin
       write(hotSeat_file,hotSeat[count]);
      end;
  end;


Procedure ChangeDetails;
  var
  count: integer;
  firstname,lastname,newphone: string[12];
  name: boolean;


  Begin
    name:=false;

        WriteLn('4 pressed,changing the phone a friend details...');



        WriteLn('Please enter your first name.');
        readln(firstname);
        WriteLn('Please enter your last name.');
        readln(lastname);

        for count:=1 to filesize(hotSeat_file) do
        begin
         if (hotSeat[count].lastname=lastname) and
         (hotSeat[count].firstname=firstname) then
        begin
        writeln('Well. We''ve found your records.');
        writeln('Please enter your new phone number < 03 ###-####>');
        readln(newphone);
        hotSeat[count].address:=newphone;
        name:=true
        end;
        end;
        if name=false then
        begin
        writeln('Sorry!  We do not have your records from your database.');
        end;
        writeln;
        write('Press <ENTER> to save changes and return to the main menu.');

        save;
        readln;

        end;

Procedure EnrolContestant;
  var   lastname:string[12];
        firstname :string[12];
        address:string[12];
        count :integer;
        name :boolean;

  Begin
    name:=false;
    writeln('Please enter your first name - if you''re new.');
    readln(firstname);
    writeln('Please enter your last name.');
    readln(lastname);
    writeln('Lastly, please enter your phone number.');
    readln(address);
    writeln('Please press <ENTER>');
    for count:=1 to filesize(hotSeat_file) do
    begin
    if (hotSeat[count].lastname=lastname) and
    (hotSeat[count].firstname=firstname) then
    begin
        name:=true;
        writeln('You''re a contestant already.');
    end;
    end;
    if (name = false) then
    begin

        numberRecords:= numberRecords+ 1;
        hotSeat[filesize(hotSeat_file)].firstname:=firstname;
        hotSeat[filesize(hotSeat_file)].lastname:=lastname;
        hotSeat[filesize(hotSeat_file)].address:=address;


  writeln('Please press <ENTER> to save your details and return to main menu.');

        readln;
        save;

    end;
  end;





Procedure GetOutOfHere;
  Begin
    WriteLn('0 pressed,exiting...');
    Sleep(5000);
    clrscr;
  End;
 Procedure Menu;
Begin

      Writeln('               M E N U');
      WriteLn('Please enter an integer in the range 1...5');
      WriteLn;
      WriteLn('  1 List all the contestants');
      WriteLn('  2 Generate the 10 finalist''s numbers');
      WriteLn('  3 Find and list the finalists');
      WriteLn('  4 Change the phone a friend details');
      WriteLn('  5 Enrol a new contestant');
      WriteLn('  0 Exit');


      Readln(User_Choice);

      Case (User_Choice) of
         1:ContestantsList;
         2:Generate10finalists;
         3:ShowFinalists;
         4:ChangeDetails;
         5:EnrolContestant;
         0:GetOutOfHere;
        end;
end;





begin //main body
Load;
repeat
menu;              {Shows the Menu on the screen}
until User_Choice = 0;  {Allows program user to Exit program}
end.

maybe it can be good,but how do you want to play with the players?
when you got the ten finalist then refresh your screen,and call your question procedure to play with the guys,and after answering save the money to the player into the file.....

I am still thinking what I want to do for the coding.

It is not easy.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.