Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit uStoppuhr;
- {$mode delphi}
- interface
- uses
- Classes, SysUtils, LCLIntf, Dialogs;
- type
- { TStoppuhr}
- TStoppuhr = class
- private
- startwert: integer;
- status: boolean;
- bestezeit: integer;
- lastround, thisround: integer;
- public
- constructor create;
- procedure startTimer;
- procedure stopTimer;
- procedure resetTimer;
- function getTime:integer;
- function getMinuten:integer;
- function getSekunden:integer;
- function getZehntel:integer;
- function getStatus:boolean;
- function getBesteZeitMinuten:integer;
- function getBesteZeitSekunden:integer;
- function getBesteZeitZehntel:integer;
- function getLastRoundMinuten: integer;
- function getLastRoundSekunden: integer;
- function getLastRoundZehntel: integer;
- procedure CheckBesteZeit;
- end;
- implementation
- { TStoppuhr}
- constructor TStoppuhr.create;
- begin
- startwert:= 0;
- bestezeit := 0;
- lastround:= 0;
- status:= false;
- end;
- procedure TStoppuhr.startTimer;
- begin
- if status = false then begin
- startwert := GetTickCount64;
- end;
- status:= true;
- end;
- procedure TStoppuhr.stopTimer;
- begin
- status:= false;
- startwert:= 0;
- end;
- procedure TStoppuhr.resetTimer;
- begin
- CheckBesteZeit;
- if status then begin
- lastround:= GetTickCount64 - startwert;
- end;
- startwert:= 0;
- status:= false;
- end;
- function TStoppuhr.getTime:integer;
- begin
- result := GetTickCount64 - startwert;
- end;
- function TStoppuhr.getMinuten:integer;
- begin
- result:= ((GetTickCount64 - startwert) div 1000) div 60;
- end;
- function TStoppuhr.getSekunden:integer;
- begin
- result:= ((GetTickCount64 - startwert) div 1000) - getMinuten*60;
- end;
- function TStoppuhr.getZehntel:integer;
- begin
- result:= ((GetTickCount64 - startwert) mod 1000);
- end;
- function TStoppuhr.getStatus:boolean;
- begin
- result := status;
- end;
- function TStoppuhr.getBesteZeitMinuten: integer;
- begin
- result:= ((bestezeit) div 1000) div 60;
- end;
- function TStoppuhr.getBesteZeitSekunden: integer;
- begin
- result:= ((bestezeit) div 1000) - getBesteZeitMinuten*60;
- end;
- function TStoppuhr.getBesteZeitZehntel: integer;
- begin
- result:= ((bestezeit) mod 1000);
- end;
- function TStoppuhr.getLastRoundMinuten: integer;
- begin
- result:= ((lastround) div 1000) div 60;
- end;
- function TStoppuhr.getLastRoundSekunden: integer;
- begin
- result:= ((lastround) div 1000) - getLastRoundMinuten*60;
- end;
- function TStoppuhr.getLastRoundZehntel: integer;
- begin
- result:= ((lastround) mod 1000);
- end;
- procedure TStoppuhr.CheckBesteZeit;
- begin
- if (bestezeit < (GetTickCount64 - startwert)) and (status = true) then begin
- bestezeit := (GetTickCount64 - startwert);
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement