⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.~pas

📁 五行软件模拟了中国五行相生相克的原理
💻 ~PAS
字号:
unit Unit1;

interface

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

const
  delta_keout=6;
  delta_kein=6;

  delta_son=10;
  delta_mother=10;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Button1: TButton;
    TrackBar1: TTrackBar;
    TrackBar2: TTrackBar;
    TrackBar3: TTrackBar;
    TrackBar4: TTrackBar;
    TrackBar5: TTrackBar;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure TrackBar1Change(Sender: TObject);
    procedure TrackBar2Change(Sender: TObject);
    procedure TrackBar3Change(Sender: TObject);
    procedure TrackBar4Change(Sender: TObject);
    procedure TrackBar5Change(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


  TWUXING=class;
  TWUXING = class(TOBJECT)
  private
  public
    NAME:String;
    Value:integer;
    Mother:TWUXING;
    Son:TWUXING;
    KeIn:TWUXING;
    KeOut:TWUXING;

  //  procedure init;
    procedure Ticket;
    function CheckValue:integer;
  end;

var
  Form1: TForm1;
  jin,mu,sui,huo,tu:twuxing;
  count:integer;
implementation

{$R *.dfm}

function TWUXING.CheckValue:integer;
var ret:integer;
begin
   if value<400 then ret:=-1;
   if (value>=400) and (value<600) then ret:=0;
   if  value>=600 then ret:=1;
   result:=ret;
end;

procedure TWUXING.ticket;
begin
   if  checkvalue=1 then
   begin
     if keout.Value+100<=self.value then keout.Value:=keout.Value-delta_keout
     else  if keout.value>(self.Value+200) then self.value:=self.value-delta_keout;

     if son.CheckValue<0 then
     begin
       if son.KeIn.CheckValue<=0 then  son.Value:=son.Value+delta_son;
     end;

     if kein.Value+200<self.value then kein.Value:=kein.Value-delta_kein
     else  if kein.Value>self.Value+100 then value:=value-delta_kein;

     //mother.Value:=mother.Value+delta_mother;
   end;

   if  checkvalue=-1 then
   begin
     if keout.Value<800 then   keout.Value:=keout.Value+delta_keout;

     //if kein.CheckValue<0 then kein.Value:=kein.Value+delta_kein;

     //if son.CheckValue>=0 then son.Value:=son.Value-delta_son;
     
     if mother.CheckValue>=0 then
     begin
       mother.Value:=mother.Value-delta_mother;
       value:=value+delta_mother;
     end;
   end;

   //if value>55 then value:=value-1;

   if value<495 then
   begin
     if (kein.value<550) then value:=value+5;
   end
   else if value>505 then
   begin
     if (kein.value>400)  then value:=value-5;
   end;


   if value>900 then value:=900;
   if value<100 then value:=100;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  jin:=twuxing.Create; jin.Value:=500;
  mu:=twuxing.Create; mu.Value:=500;
  sui:=twuxing.Create; sui.Value:=500;
  huo:=twuxing.Create; huo.Value:=500;
  tu:=twuxing.Create; tu.Value:=500;

  jin.Mother:=tu;  jin.Son:=sui; jin.KeIn:=huo; jin.KeOut:=mu;  jin.NAME:='金';
  mu.Mother:=sui;  mu.Son:=huo;  mu.KeIn:=jin;  mu.KeOut:=tu;   mu.name:='木';
  sui.Mother:=jin; sui.Son:=mu;  sui.KeIn:=tu;  sui.KeOut:=huo;  sui.name:='水';
  huo.Mother:=mu;  huo.Son:=tu;  huo.KeIn:=sui;  huo.KeOut:=jin;  huo.name:='火';
  tu.Mother:=huo;  tu.Son:=jin;  tu.KeIn:=mu;    tu.KeOut:=sui;   tu.name:='土';

  count:=0;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  jin.Ticket;  trackbar1.Position:=jin.Value;   application.ProcessMessages;
  mu.Ticket ;  trackbar2.Position:=mu.Value;   application.ProcessMessages;
  sui.Ticket;  trackbar3.Position:=sui.Value;   application.ProcessMessages;
  huo.Ticket;  trackbar4.Position:=huo.Value;   application.ProcessMessages;
  tu.Ticket;   trackbar5.Position:=tu.Value;   application.ProcessMessages;
//  jin.ticket;     application.ProcessMessages;

  edit1.Text:=inttostr(jin.Value);
  edit2.Text:=inttostr(mu.Value);
  edit3.Text:=inttostr(sui.Value);
  edit4.Text:=inttostr(huo.Value);
  edit5.Text:=inttostr(tu.Value);
end;


procedure TForm1.TrackBar1Change(Sender: TObject);
begin
  jin.Value:=trackbar1.Position; 
end;

procedure TForm1.TrackBar2Change(Sender: TObject);
begin
 mu.Value:=trackbar2.Position;
end;

procedure TForm1.TrackBar3Change(Sender: TObject);
begin
  sui.Value:=trackbar3.Position;
end;

procedure TForm1.TrackBar4Change(Sender: TObject);
begin
  huo.Value:=trackbar4.Position;
end;

procedure TForm1.TrackBar5Change(Sender: TObject);
begin
   tu.Value:=trackbar5.Position;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  timer1.Enabled:= not timer1.Enabled;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -