无法调试代码 delphi

Trouble debugging code delphi

我在调试以下代码时遇到问题,明天要考试,我真的需要帮助!每当我尝试更改组合框时,程序都会停止响应。如果您发现问题,请告诉我,我相信它非常明显...

提前致谢 克里斯

编辑:我真的是新来的,很抱歉我没有说得更具体。我已经添加了所有代码。我最初没有这样做的唯一原因是因为我认为问题最有可能与 TForm1.ComboBox1Change 程序有关,因为 .exe 崩溃(windows 表示它没有响应,我附上了一个图像)每当我更改组合框时。如果我浪费了任何人的时间,我很抱歉。当我说我在调试它时遇到问题时,我也是不正确的。我的意思是我正在努力寻找导致此问题的问题。我也附上了任务简介。

unit VehicleManager_u;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Car, Vcl.StdCtrls, Vcl.Samples.Spin;

type
  TForm1 = class(TForm)
    ComboBox1: TComboBox;
    Edit1: TEdit;
    SpinEdit1: TSpinEdit;
    Edit2: TEdit;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
  private
    { Private declarations }
    Car1 : TCar;
    Car2 : TCar;
    Car3 : TCar;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
  begin
    Car1 := TCar.Create('', 0, 0.0);
    Car2 := TCar.Create('', 0, 0.0);
    Car3 := TCar.Create('', 0, 0.0);
  end;

procedure TForm1.ComboBox1Change(Sender: TObject);
  begin

    If ComboBox1.Text = 'Car 1' then
      begin
        Edit1.Text := Car1.GetMake;
        SpinEdit1.Value := Car1.GetYearMade;
        Edit2.Text := FloatToStr(Car1.GetValue);
      end

    Else if ComboBox1.Text = 'Car 2' then
      begin
        SpinEdit1.Value := Car2.GetYearMade;
        Edit2.Text := FloatToStr(Car2.GetValue);
      end

    Else if ComboBox1.Text = 'Car 3' then
      begin
        Edit1.Text := Car3.GetMake;
        SpinEdit1.Value := Car3.GetYearMade;
        Edit2.Text := FloatToStr(Car3.GetValue);
      end;
  end;

procedure TForm1.Button1Click(Sender: TObject);
  begin

    If ComboBox1.Text = 'Car 1' then
      begin
        Car1.SetMake(Edit1.Text);
        Car1.SetYearMade(SpinEdit1.Value);
        Car1.SetValue(StrToFloat(Edit2.Text));
      end

    Else if ComboBox1.Text = 'Car 2' then
      begin
        Car2.SetMake(Edit1.Text);
        Car2.SetYearMade(SpinEdit1.Value);
        Car2.SetValue(StrToFloat(Edit2.Text));
      end

    Else if ComboBox1.Text = 'Car 3' then
      begin
        Car3.SetMake(Edit1.Text);
        Car3.SetYearMade(SpinEdit1.Value);
        Car3.SetValue(StrToFloat(Edit2.Text));
      end;
  end;

end.

这是来自对象的代码:

unit Car;

interface
  type
    TCar = class(TObject)

    private
      Make : String;
      YearMade : Integer;
      Value : Double;

    public
      constructor Create(MakeIn : String; YearMadeIn : Integer; ValueIn : Double);
      procedure SetMake(MakeIn : String);
      function GetMake: String;
      procedure SetYearMade(YearMadeIn : Integer);
      function GetYearMade : Integer;
      procedure SetValue(ValueIn : Double);
      function GetValue : Double;
      function ToString : String;
    end;

implementation

  uses
    SysUtils;

  constructor TCar.Create(MakeIn : String; YearMadeIn : Integer; ValueIn : Double);
    begin
      Make := MakeIn;
      YearMade := YearMadeIn;
      Value := ValueIn;
    end;

  procedure TCar.SetMake(MakeIn: string);
    begin
      Make := MakeIn;
    end;

  function TCar.GetMake;
    begin
      Result := GetMake;
    end;

  procedure TCar.SetYearMade(YearMadeIn: Integer);
    begin
      YearMade := YearMadeIn;
    end;

  function TCar.GetYearMade;
    begin
      Result := GetYearMade;
    end;

  procedure TCar.SetValue(ValueIn: Double);
    begin
      Value := ValueIn;
    end;

  function TCar.GetValue;
    begin
      Result := GetValue;
    end;

  function TCar.ToString;
    begin
      Result := 'Make: ' + Make + ', Year Made: ' + IntToStr(YearMade) + ', Vale: R' + FloatToStr(Value);
    end;
end.

Here is a screenshot of the "error" message

Task brief

我在高中时问过这个问题,对所有与编码相关的事情都非常缺乏经验。 Tom Brunberg in his comment. The Get.... methods of TCar were calling themselves recursively instead of returning the value of the corresponding variable in the class. However, as pointed out by both J... and Tom Brunberg 指出了问题(感谢两者),真正的问题是我不知道如何使用我的调试器(或者真正的调试是什么)。如果我使用断点并逐步执行我的代码,这将立即变得明显。