Добавил:
masterdos
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Курсовая работа / KURSOVA_ROBOTA / Дроби / CheckUnit
.cpp#include <vcl.h>
#pragma hdrstop
#include "CheckUnit.h"
#include "FracUnit.h"
#include "CalculateFrac.h"
#include "Math.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TCheckForm *CheckForm;
//---------------------------------------------------------------------------
__fastcall TCheckForm::TCheckForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TCheckForm::FormActivate(TObject *Sender)
{
Edit1->Clear(); Edit2->Clear(); Edit3->Clear(); Edit4->Clear();
Button1->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TCheckForm::Button2Click(TObject *Sender)
{
Edit1->Clear(); Edit2->Clear(); Edit3->Clear(); Edit4->Clear();
Button1->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TCheckForm::Button3Click(TObject *Sender)
{
CheckForm->Close();
MainForm->Show();
}
//---------------------------------------------------------------------------
void __fastcall TCheckForm::Edit1KeyPress(TObject *Sender, char &Key)
{
if(((Key>='0')&&(Key<='9'))||(Key==VK_BACK)||(Key=='-'))
return;
if(Key==VK_RETURN)
Edit2->SetFocus();
Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TCheckForm::Edit2KeyPress(TObject *Sender, char &Key)
{
if(((Key>='0')&&(Key<='9'))||(Key==VK_BACK))
return;
if(Key==VK_RETURN)
Edit3->SetFocus();
Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TCheckForm::Edit3KeyPress(TObject *Sender, char &Key)
{
if(((Key>='0')&&(Key<='9'))||(Key==VK_BACK)||(Key=='-'))
return;
if(Key==VK_RETURN)
Edit4->SetFocus();
Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TCheckForm::Edit4KeyPress(TObject *Sender, char &Key)
{
if(((Key>='0')&&(Key<='9'))||(Key==VK_BACK))
return;
if(Key==VK_RETURN)
Button1->SetFocus();
Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TCheckForm::Button1Click(TObject *Sender)
{
int a,b,c,d;
if(((Edit1->Text).Length()==0)||((Edit2->Text).Length()==0)||
((Edit3->Text).Length()==0)||((Edit4->Text).Length()==0))
{
ShowMessage("Заповніть всі поля!");
return;
}
a=StrToInt(Edit1->Text);
b=StrToInt(Edit2->Text);
c=StrToInt(Edit3->Text);
d=StrToInt(Edit4->Text);
if((d==0)||(b==0))
{
ShowMessage("Ділення на нуль!!");
return;
}
Button1->Enabled=false;
CalculateFrac *Calculate=new CalculateFrac;
int check=Calculate->CheckFrac(a,b,c,d);
if (check==1)
ShowMessage("Дроби рівні.");
else
if (check==2)
ShowMessage("Перший дріб більше другого.");
else
ShowMessage("Другий дріб більше першого.");
}
//---------------------------------------------------------------------------
Соседние файлы в папке Дроби