A simple game where all words of a long phrase is scrambled and after need to be assembled

Hello Guys,

I need a small project where a phase could be scrambled, see the example:


This is the correct sentence
" My dog was playing with a ball in the gardem when a white horse appeared to play too"

This is the scrambled sentence

"Horse playing gardem when appeared is too ball was my  white with horse to in"

This must be done randomly.

Thanks
Alexandre
LVL 1
hidrauAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pcsentinelCommented:
************UNIT CODE*****************
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Memo2: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  lr: integer;
      lS: TStringlist;
  lout: string;
begin
Randomize;
ls:=TStringlist.create;
ls.commatext:=memo1.TExt;
while ls.count>0 do
begin
      lr:=Random(ls.count);
      lout:=lout+ ' '+ls[lr];
  ls.Delete(lr);
end;
  memo2.lines.add(lout);
freeandNil(ls);

end;

end.


******************FORM CODE************************
object Form1: TForm1
  Left = 248
  Top = 106
  Width = 696
  Height = 480
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Memo1: TMemo
    Left = 288
    Top = 20
    Width = 185
    Height = 89
    Lines.Strings = (
      'My dog was playing with a ball in the '
      'gardem when a white horse appeared '
      'to play too')
    TabOrder = 0
  end
  object Memo2: TMemo
    Left = 292
    Top = 128
    Width = 185
    Height = 89
    Lines.Strings = (
      'Memo2')
    TabOrder = 1
  end
  object Button1: TButton
    Left = 116
    Top = 72
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 2
    OnClick = Button1Click
  end
end

regards

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hidrauAuthor Commented:
Hy pcsentinel,
It worked very well, thanks for your help

Only curiosity, where are you from?
pcsentinelCommented:
U.K. why

thanks for the points btw
hidrauAuthor Commented:
Hello pcsentinel
Only to know a little bit about the people here.
There are many good programmers in UK and here in my country too.

Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.