AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Gleitkomma Problem

Ein Thema von Garrad · begonnen am 7. Apr 2008 · letzter Beitrag vom 8. Apr 2008
 
Garrad
(Gast)

n/a Beiträge
 
#1

Gleitkomma Problem

  Alt 7. Apr 2008, 20:27
Ich hab für die schule nen Programm geschrieben. Jetztt kommt immer der fehler mit ... ist kein gültiger Gleitkommawert. Ich hab keine Ahnung woran das liegen könnte wär nett wenn mir jemand helfen könnte.
Delphi-Quellcode:
type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    RadioGroup1: TRadioGroup;
    GroupBox1: TGroupBox;
    Label10: TLabel;
    Label11: TLabel;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    function ziehen:integer;
    function gegner:real;
    function Gewonnen:real;
    function Verloren:real;
    procedure FormCreate(Sender: TObject);
      private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var b,c,w,L:integer;
  Form1: TForm1;

implementation

{$R *.dfm}
function Tform1.ziehen:integer;
var a:integer;
begin
randomize;
a:=1+random(13);
    if a=0 then label1.Caption:='zwei';
    if a=1 then label1.Caption:='drei';
    if a=2 then label1.Caption:='vier';
    if a=3 then label1.Caption:='fünf';
    if a=4 then label1.Caption:='sechs';
    if a=5 then label1.Caption:='sieben';
    if a=6 then label1.Caption:='acht';
    if a=7 then label1.Caption:='neun';
    if a=8 then label1.Caption:='zehn';
    if a=9 then label1.Caption:='Bube';
    if a=10 then label1.Caption:='Dame';
    if a=11 then label1.Caption:='König';
    if a=12 then label1.Caption:='Ass';


        if a=0 then b:=b+2;
           if a=1 then b:=b+3;
           if a=2 then b:=b+4;
           if a=3 then b:=b+5;
           if a=4 then b:=b+6;
           if a=5 then b:=b+7;
           if a=6 then b:=b+8;
           if a=7 then b:=b+9;
           if a=8 then b:=b+10;
           if a=9 then b:=b+10;
           if a=10 then b:=b+10;
           if a=11 then b:=b+10;
           if a=12 then b:=b+10;
ziehen:=b;

end;
function Tform1.gegner:real;
var i:integer; a:real;
begin
label1.visible:=false;
b:=0;
repeat
ziehen;
until b>=17;
a:=strtofloat(Label5.caption);
label4.caption:=inttostr(b);
label1.visible:=false;
if b>21 then Gewonnen //gleitkomma Problem
else
begin
if b>a then Verloren; //Gleitkomma Problem
if b=21 then Verloren;
if b=a then label9.Caption:='unentschieden';
if a>b then Gewonnen //Gleitkomma Problem
end;
c:=100;
For i:=0 to 2 Do
begin
RadioGroup1.Items.Delete(i);
RadioGroup1.Items.Insert(i,(floattostr(strtofloat(label11.caption)*(0.4+i/10))));
end;
Button1.Caption:='Neues Spiel';
Button2.Enabled:=false;


end;


function Tform1.Gewonnen:real;
var i:integer;

begin
label9.caption:='Gewonnen';

For i:=0 to 2 do
  begin if RadioGroup1.ItemIndex=i
  then label11.Caption:=inttostr(strtoint(label11.caption)+strtoint(RadioGroup1.Items.Strings[i]));
  end;

For i:=0 to 2 Do
begin
RadioGroup1.Items.Delete(i);
RadioGroup1.Items.Insert(i,(floattostr(strtofloat(label11.caption)*0.4)));
end;
label7.Caption:=floattostr (strtofloat(label7.Caption)+1);
b:=0;
Button1.Caption:='Neues Spiel';
Button2.Enabled:=false;
end;


function Tform1.Verloren:real;
var i:integer;
begin

label9.caption:='Verloren';

For i:=0 to 2 do
  begin if RadioGroup1.ItemIndex=i
  then label11.Caption:=inttostr(strtoint(label11.Caption)-strtoint(RadioGroup1.Items.Strings[i]));
  end;

For i:=0 to 2 Do
begin
RadioGroup1.Items.Delete(i);
RadioGroup1.Items.Insert(i,(floattostr(strtofloat(label11.caption)*0.4)));
end;
label8.Caption:=floattostr (strtofloat(label8.Caption)+1);
b:=0;
Button1.Caption:='Neues Spiel';
Button2.Enabled:=false;

end;


procedure TForm1.Button1Click(Sender: TObject);
var a:real;
begin
if c=100 then
begin
Button1.Caption:='Karte ziehen';
Button2.Enabled:=true;
Label5.Caption:='0';
label1.Caption:=' ';
label1.visible:=true;
label4.Caption:=' ';
label9.Caption:=' ';
c:=0;
b:=0;
end
else
begin
if b>21 then verloren //gleitkomma problem
else
            begin
            if b=21 then gegner
              else
                begin
                a:=ziehen;
                Label5.Caption:=floattostr(a);
                end;
            end;

if a>21 then //gleitkomma problem

if a=21 then gegner

end;
end;



procedure TForm1.Button2Click(Sender: TObject);
begin
gegner;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
c:=100;
RadioGroup1.Items.Insert(0,(floattostr(strtofloat(label11.caption)*0.4)));
RadioGroup1.Items.insert(1,(floattostr(strtofloat(label11.caption)*0.3)));
RadioGroup1.Items.insert(2,(floattostr(strtofloat(label11.caption)*0.2)));


end;

end.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:02 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz