Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions 20_Task/M2/Project_Calc.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
program Project_Calc;

uses
Vcl.Forms,
uCalcForm in 'uCalcForm.pas' {frmCalc},
USplash in 'USplash.pas' {SplashForm},
Vcl.Themes,
Vcl.Styles;

{$R *.res}

begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
SplashForm := TSplashForm.Create(Application);
SplashForm.Show;
SplashForm.Refresh;
TStyleManager.TrySetStyle('Silver');
Application.CreateForm(TfrmCalc, frmCalc);
SplashForm.Hide;
SplashForm.Free;
Application.Run;
end.
624 changes: 624 additions & 0 deletions 20_Task/M2/Project_Calc.dproj

Large diffs are not rendered by default.

Binary file added 20_Task/M2/Project_Calc.res
Binary file not shown.
2,094 changes: 2,094 additions & 0 deletions 20_Task/M2/USplash.dfm

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions 20_Task/M2/USplash.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
unit USplash;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
Vcl.Imaging.jpeg;

type
TSplashForm = class(TForm)
Panel1: TPanel;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;

var
SplashForm: TSplashForm;

implementation

{$R *.dfm}

end.
185 changes: 185 additions & 0 deletions 20_Task/M2/uCalcForm.dfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
object frmCalc: TfrmCalc
Left = 0
Top = 0
Caption = 'frmCalc'
ClientHeight = 368
ClientWidth = 296
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object displayLabel: TLabel
Left = 8
Top = 8
Width = 274
Height = 65
Alignment = taRightJustify
AutoSize = False
Caption = '0'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -48
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object Button1: TButton
Left = 8
Top = 97
Width = 64
Height = 64
Caption = '7'
TabOrder = 0
OnClick = ButtonNumberClick
end
object Button2: TButton
Left = 78
Top = 97
Width = 64
Height = 64
Caption = '8'
TabOrder = 1
OnClick = ButtonNumberClick
end
object Button3: TButton
Left = 148
Top = 97
Width = 64
Height = 64
Caption = '9'
TabOrder = 2
OnClick = ButtonNumberClick
end
object Button4: TButton
Left = 8
Top = 166
Width = 64
Height = 64
Caption = '4'
TabOrder = 3
OnClick = ButtonNumberClick
end
object Button5: TButton
Left = 78
Top = 166
Width = 64
Height = 64
Caption = '5'
TabOrder = 4
OnClick = ButtonNumberClick
end
object Button6: TButton
Left = 148
Top = 166
Width = 64
Height = 64
Caption = '6'
TabOrder = 5
OnClick = ButtonNumberClick
end
object Button7: TButton
Left = 8
Top = 233
Width = 64
Height = 64
Caption = '1'
TabOrder = 6
OnClick = ButtonNumberClick
end
object Button8: TButton
Left = 78
Top = 233
Width = 64
Height = 64
Caption = '2'
TabOrder = 7
OnClick = ButtonNumberClick
end
object Button9: TButton
Left = 148
Top = 233
Width = 64
Height = 64
Caption = '3'
TabOrder = 8
OnClick = ButtonNumberClick
end
object Button10: TButton
Left = 8
Top = 302
Width = 64
Height = 65
Caption = 'ac'
TabOrder = 9
OnClick = ButtonClearClick
end
object Button11: TButton
Left = 78
Top = 302
Width = 64
Height = 65
Caption = '0'
TabOrder = 10
OnClick = ButtonNumberClick
end
object Button12: TButton
Left = 148
Top = 302
Width = 64
Height = 65
Caption = '='
TabOrder = 11
OnClick = ButtonEqualClick
OnKeyPress = Button12KeyPress
end
object Button13: TButton
Left = 218
Top = 151
Width = 64
Height = 50
Caption = '+'
TabOrder = 12
OnClick = ButtonOperatorClick
end
object Button14: TButton
Left = 218
Top = 207
Width = 64
Height = 50
Caption = '-'
TabOrder = 13
OnClick = ButtonOperatorClick
end
object Button15: TButton
Left = 218
Top = 263
Width = 64
Height = 50
Caption = '*'
TabOrder = 14
OnClick = ButtonOperatorClick
end
object Button16: TButton
Left = 218
Top = 320
Width = 64
Height = 47
Caption = '/'
TabOrder = 15
OnClick = ButtonOperatorClick
end
object Button17: TButton
Left = 218
Top = 97
Width = 64
Height = 49
Caption = 'delete'
TabOrder = 16
OnClick = ButtonDeleteClick
end
end
156 changes: 156 additions & 0 deletions 20_Task/M2/uCalcForm.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
unit uCalcForm;

interface

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

type
TfrmCalc = class(TForm)
displayLabel: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Button11: TButton;
Button12: TButton;
Button13: TButton;
Button14: TButton;
Button15: TButton;
Button16: TButton;
Button17: TButton;
procedure ButtonNumberClick(Sender: TObject);
procedure ButtonOperatorClick(Sender: TObject);
procedure ButtonEqualClick(Sender: TObject);
procedure ButtonClearClick(Sender: TObject);
procedure ButtonDeleteClick(Sender: TObject);
procedure Button12KeyPress(Sender: TObject; var Key: Char);


private
{ Private declarations }
public
{ Public declarations }
end;

var
frmCalc: TfrmCalc;

implementation

{$R *.dfm}
var
typing : boolean = false; //Ÿ���������� üũ
firstNumber: integer;
secondNumber: integer;
operator :integer;
result: real;
rep: boolean = false; //�����ڸ� �ݺ��ϴ��� ���� üũ
//���ڹ�ư�� ��������

procedure TfrmCalc.ButtonNumberClick(Sender: TObject);
begin
rep := false;
//�ݺ��� Ǯ����
if typing then
displayLabel.Caption := displayLabel.Caption + (sender as TButton).Caption
else
begin
displayLabel.Caption := (sender as TButton).Caption;
typing := true;
end;

end;
//���� ������ ���ڸ� ����

procedure TfrmCalc.ButtonDeleteClick(Sender: TObject);
var s: string;
begin
s := displayLabel.Caption;
displayLabel.Caption := copy(s,0,length(s)-1);
end;
//�޸𸮿� ����� ��簪�� ����

procedure TfrmCalc.Button12KeyPress(Sender: TObject; var Key: Char);
begin
if (Key = #13) then
begin
Button12.Click;
end;

end;

procedure TfrmCalc.ButtonClearClick(Sender: TObject);
begin
displayLabel.Caption := '';
typing := false;
firstNumber:= 0;
secondNumber:= 0;
result:= 0;
rep := false;
end;
//������ ��ư�� �������� firstNumber�� ���÷��̶��� ���� ����
//�����ڸ� ���ڷ� �з�

procedure TfrmCalc.ButtonOperatorClick(Sender: TObject);

begin

if rep then
begin
showmessage('���ڸ� �Է��ϼ���');
end
else
firstNumber := strtoint(displayLabel.caption);
displayLabel.caption := '';
if (sender as TButton).Caption = '+' then
operator := 1
else if (sender as TButton).Caption = '-' then
operator := 2
else if (sender as TButton).Caption = '*' then
operator := 3
else if (sender as TButton).Caption = '/' then
operator := 4;
rep := true
end;
//=��ư�� �������� ó��

procedure TfrmCalc.ButtonEqualClick(Sender: TObject);

begin
secondNumber := strtoint(displayLabel.caption);
if rep then
begin
showmessage('���ڸ� �Է��ϼ���');
end
else
case operator of
1:
begin
result := firstNumber + secondNumber;
end;
2:
begin
result := firstNumber - secondNumber;
end;
3:
begin
result := firstNumber * secondNumber;
end;
4:
begin
result := firstNumber / secondNumber;
end;
end;
displayLabel.caption := floattostr(result);
typing := false;
rep := true;
end;
end.