For ループに問題があります。ランダムな量の買い物と金額をカウントする必要がありますが、以下のように順番に表示します。また、スプリーの量を取得して前に表示する必要があります。
現在、酒宴の合計は 0 として表示され、ランダムではない 20 酒宴のみが表示されます。
合計 3 回の買い物に勝ちました
酒宴 #1 では、R100 を支払うことができます
酒宴 #2 では、R341 を使うことができます
酒宴 #3 では、R451 を使うことができます
トータルコスト:= 0;
合計:= 0;
ListHead := 'Max per spree is R500.00 Max number of sprees 20';
lstNumber.Items.Add(ListHead);
SpreeWon := 'You have won ' + inttostr(Sum) + ' shopping sprees';
lstNumber.Items.Add(SpreeWon);
for Count := 0 to 20 do
begin
Sum := Random(Count);
Prize := Random(500) + 1;
ListItems := 'On spree # ' + inttostr(Sum) + ' you may spend R' + inttostr(Prize);
lstNumber.Items.Add(ListItems);
TotalCost := TotalCost + Prize;
end;
begin
Cost := 'Total prize value : R' + inttostr(TotalCost);
lstNumber.Items.Add(Cost);
end;