Prześlij pliki do ''

This commit is contained in:
Aleksander Misztal 2019-02-09 02:48:18 +00:00
parent ef31299cd7
commit 43f57fb4ee
4 changed files with 465 additions and 0 deletions

218
Unit3.cpp Normal file
View File

@ -0,0 +1,218 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button10Click(TObject *Sender)
{
Edit1->Text=Edit1->Text+0;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button7Click(TObject *Sender)
{
Edit1->Text=Edit1->Text+1;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button8Click(TObject *Sender)
{
Edit1->Text=Edit1->Text+2;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button9Click(TObject *Sender)
{
Edit1->Text=Edit1->Text+3;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button4Click(TObject *Sender)
{
Edit1->Text=Edit1->Text+4;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button5Click(TObject *Sender)
{
Edit1->Text=Edit1->Text+5;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button6Click(TObject *Sender)
{
Edit1->Text=Edit1->Text+6;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button1Click(TObject *Sender)
{
Edit1->Text=Edit1->Text+7;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button2Click(TObject *Sender)
{
Edit1->Text=Edit1->Text+8;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button3Click(TObject *Sender)
{
Edit1->Text=Edit1->Text+9;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button13Click(TObject *Sender)
{
if (mnozenie==true){
y=Edit1->Text.ToDouble();
x=x*y;
Edit1->Text="";
}
else{
x=Edit1->Text.ToDouble();
mnozenie=true;
Edit1->Clear();
dodawanie=false;
odejmowanie=false;
dzielenie=false;
przecinek=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button12Click(TObject *Sender)
{
if (dzielenie==true){
y=Edit1->Text.ToDouble();
x=x/y;
Edit1->Text="";
}
else{
x=Edit1->Text.ToDouble();
dzielenie=true;
Edit1->Clear();
dodawanie=false;
odejmowanie=false;
mnozenie=false;
przecinek=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button14Click(TObject *Sender)
{
if (dodawanie==true){
y=Edit1->Text.ToDouble();
x=x+y;
Edit1->Text="";
}
else{
x=Edit1->Text.ToDouble();
dodawanie=true;
Edit1->Clear();
mnozenie=false;
odejmowanie=false;
dzielenie=false;
przecinek=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button15Click(TObject *Sender)
{
if (odejmowanie==true){
y=Edit1->Text.ToDouble();
x=x-y;
Edit1->Text="";
}
else{
x=Edit1->Text.ToDouble();
odejmowanie=true;
Edit1->Clear();
dodawanie=false;
mnozenie=false;
dzielenie=false;
przecinek=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button16Click(TObject *Sender)
{
x=0;
y=0;
Edit1->Text="";
dodawanie=false;
odejmowanie=false;
mnozenie=false;
dzielenie=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button17Click(TObject *Sender)
{
if(dodawanie==true){
y=Edit1->Text.ToDouble();
x=x+y;
Edit1->Text=x;
x=0;
y=0;
przecinek=false;
}
if(odejmowanie==true){
y=Edit1->Text.ToDouble();
x=x-y;
Edit1->Text=x;
x=0;
y=0;
przecinek=false;
}
if(mnozenie==true){
y=Edit1->Text.ToDouble();
x=x*y;
Edit1->Text=x;
x=0;
y=0;
przecinek=false;
}
if(dzielenie==true){
y=Edit1->Text.ToDouble();
x=x/y;
Edit1->Text=x;
x=0;
y=0;
przecinek=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button11Click(TObject *Sender)
{
if (!przecinek){
AnsiString cyfra=Edit1->Text;
cyfra+=',';
Edit1->Text=cyfra;
przecinek=true;
}
}
//---------------------------------------------------------------------------

183
Unit3.dfm Normal file
View File

@ -0,0 +1,183 @@
object Form3: TForm3
Left = 1045
Top = 225
Width = 673
Height = 675
BorderIcons = [biSystemMenu, biMinimize]
Caption = 'Kalkulator'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 120
TextHeight = 16
object Button1: TButton
Left = 112
Top = 160
Width = 75
Height = 57
Caption = '7'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 200
Top = 160
Width = 75
Height = 57
Caption = '8'
TabOrder = 1
OnClick = Button2Click
end
object Button3: TButton
Left = 288
Top = 160
Width = 75
Height = 57
Caption = '9'
TabOrder = 2
OnClick = Button3Click
end
object Button4: TButton
Left = 112
Top = 232
Width = 75
Height = 57
Caption = '4'
TabOrder = 3
OnClick = Button4Click
end
object Button5: TButton
Left = 200
Top = 232
Width = 75
Height = 57
Caption = '5'
TabOrder = 4
OnClick = Button5Click
end
object Button6: TButton
Left = 288
Top = 232
Width = 75
Height = 57
Caption = '6'
TabOrder = 5
OnClick = Button6Click
end
object Button7: TButton
Left = 112
Top = 304
Width = 75
Height = 57
Caption = '1'
TabOrder = 6
OnClick = Button7Click
end
object Button8: TButton
Left = 200
Top = 304
Width = 75
Height = 57
Caption = '2'
TabOrder = 7
OnClick = Button8Click
end
object Button9: TButton
Left = 288
Top = 304
Width = 75
Height = 57
Caption = '3'
TabOrder = 8
OnClick = Button9Click
end
object Button10: TButton
Left = 112
Top = 376
Width = 161
Height = 57
Caption = '0'
TabOrder = 9
OnClick = Button10Click
end
object Button11: TButton
Left = 288
Top = 376
Width = 75
Height = 57
Caption = ','
TabOrder = 10
OnClick = Button11Click
end
object Button12: TButton
Left = 376
Top = 160
Width = 75
Height = 57
Caption = '/'
TabOrder = 11
OnClick = Button12Click
end
object Button13: TButton
Left = 376
Top = 232
Width = 75
Height = 57
Caption = '*'
TabOrder = 12
OnClick = Button13Click
end
object Button14: TButton
Left = 376
Top = 304
Width = 75
Height = 57
Caption = '+'
TabOrder = 13
OnClick = Button14Click
end
object Button15: TButton
Left = 376
Top = 376
Width = 75
Height = 57
Caption = '-'
TabOrder = 14
OnClick = Button15Click
end
object Button16: TButton
Left = 464
Top = 160
Width = 75
Height = 129
Caption = 'C'
TabOrder = 15
OnClick = Button16Click
end
object Button17: TButton
Left = 464
Top = 304
Width = 75
Height = 129
Caption = '='
TabOrder = 16
OnClick = Button17Click
end
object Edit1: TEdit
Left = 112
Top = 96
Width = 425
Height = 37
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -23
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 17
end
end

64
Unit3.h Normal file
View File

@ -0,0 +1,64 @@
//---------------------------------------------------------------------------
#ifndef Unit3H
#define Unit3H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm3 : public TForm
{
__published: // IDE-managed Components
TButton *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;
TEdit *Edit1;
void __fastcall Button10Click(TObject *Sender);
void __fastcall Button7Click(TObject *Sender);
void __fastcall Button8Click(TObject *Sender);
void __fastcall Button9Click(TObject *Sender);
void __fastcall Button4Click(TObject *Sender);
void __fastcall Button5Click(TObject *Sender);
void __fastcall Button6Click(TObject *Sender);
void __fastcall Button1Click(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
void __fastcall Button3Click(TObject *Sender);
void __fastcall Button13Click(TObject *Sender);
void __fastcall Button12Click(TObject *Sender);
void __fastcall Button14Click(TObject *Sender);
void __fastcall Button15Click(TObject *Sender);
void __fastcall Button16Click(TObject *Sender);
void __fastcall Button17Click(TObject *Sender);
void __fastcall Button11Click(TObject *Sender);
private: // User declarations
public: // User declarations
double x;
double y;
char znak;
bool przecinek;
char dodawanie;
char odejmowanie;
char mnozenie;
char dzielenie;
__fastcall TForm3(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm3 *Form3;
//---------------------------------------------------------------------------
#endif

BIN
Unit3.obj Normal file

Binary file not shown.