Re: Setting symbols randomly

Posted by Rupert on April 04, 2005

In Reply to: Setting symbols randomly posted by cmarques

I've been set to program a fruit machine.
I'm unsure display the different possible combinations.
Any suggestions? :)

Put the symbols in an array, for example an array of 10 strings:

var
  Symbols: array[0..9] of string;

Somewhere at the beginning of the program, fill the array:

  Symbols[0] := 'Apple';
  Symbols[1] := 'Banana';
  //...and so on 

Say that you must randomly select 3 symbols, that are to be stored in string variables S1, S2 and S3:

begin
  Randomize;
  S1 := Symbols(Random(10));
  S2 := Symbols(Random(10));
  S3 := Symbols(Random(10));
  // Show the symbols:...
end;