Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Kurs_STP_13.docx
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
70 Кб
Скачать
☆

Void SetOperation(tOprtn toprtn) {

this->controller->PrepareOperation(gcnew TFrac(Controller<TFrac>::SysToStd(this->textBox1->Text)), toprtn);

this->controller->CurOperation = this->arithmeticOperation;

this->controller->OnPrepare = true;

this->controller->OnOperationClicked = true;

this->textBox1->Text = Controller<TFrac>::StdToSys(this->controller->Result->getStrFrac());

}

Void SetFunction(tFunc tfunc) {

this->controller->PrepareFunction(gcnew TFrac(Controller<TFrac>::SysToStd(this->textBox1->Text)), tfunc);

this->controller->CurOperation = this->functionOperation;

this->controller->Run();

this->controller->PostAction();

this->textBox1->Text = Controller<TFrac>::StdToSys(this->controller->Operand->getStrFrac());

}

void ButtonNumbersClicked(String^ text) {

if (this->controller->OnPrepare) {

this->textBox1->Text = "";

this->controller->OnPrepare = false;

}

if (this->textBox1->Text->StartsWith("0")) {

this->textBox1->Text = "0\\0";

return;

}

int pos = this->textBox1->Text->IndexOf("\\");

if (pos > -1) {

String ^ str = this->textBox1->Text->Substring(pos + 1);

String ^ str1 = this->textBox1->Text->Substring(0, pos);

if (str->StartsWith("0")) {

this->textBox1->Text = str1 + "\\";

return;

}

}

this->textBox1->Text = this->textBox1->Text + text;

}

void ResultClicked() {

if (this->controller->OnOperationClicked) {

this->controller->Operand = gcnew TFrac(Controller<TFrac>::SysToStd(this->textBox1->Text));

this->controller->OnOperationClicked = false;

}

this->controller->Run();

this->textBox1->Text = Controller<TFrac>::StdToSys(this->controller->Result->getStrFrac());

}

void BackSpace() {

if (!this->textBox1->Text->Length)

return;

this->textBox1->Text = this->textBox1->Text->Substring(0, this->textBox1->Text->Length - 1);

}

void CE() {

this->textBox1->Text = "0\\0";

this->controller->OnPrepare = true;

}

void Reset() {

this->controller->ResetController();

this->textBox1->Text = Controller<TFrac>::StdToSys(this->controller->Result->getStrFrac());

}

#pragma endregion

private: System::Void button23_Click(System::Object^ sender, System::EventArgs^ e) {

BackSpace();

}

private: System::Void button25_Click(System::Object^ sender, System::EventArgs^ e) {

CE();

}

private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {

this->controller = gcnew Controller<TFrac>();

this->arithmeticOperation = gcnew ArithmeticOperation<TFrac>();

this->functionOperation = gcnew FunctionOperation<TFrac>();

this->textBox1->Text = Controller<TFrac>::StdToSys(this->controller->Result->getStrFrac());

this->controller->OnPrepare = true;

}

private: System::Void button27_Click(System::Object^ sender, System::EventArgs^ e) {

SetOperation(Sub);

}

};

}

Operation.cpp

#pragma once

#include "stdafx.h"

#include "TProc.cpp"

#include "TMemory.cpp"

#include "TFrac.cpp"

template <class T>

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]