Файл: Программные средства создания клиентских программ.pdf

ВУЗ: Не указан

Категория: Курсовая работа

Дисциплина: Не указана

Добавлен: 31.03.2023

Просмотров: 109

Скачиваний: 1

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

#include <windows.h>

#include <iostream>

#include "button.h"

#include <string>

//#include "Toform.h"

using namespace std; //объявление пространства имен std

// класс elevator

class elevator {

public:

button bt; // переменная класса button

int door, floor; // переменная состояния дверей лифта, переменная положения лифта

elevator(int p, int p1, bool p3) :bt(p3) { door = p; floor = p1; } //конструктор класса

void up() {

// функция для поднятия лифта

floor++;// прибавляем этаж

cout << "\n Лифт поднимается на " << floor << " этаж" << endl; // вывод информации в консоли

}

void down() {

// функция для спуска лифта

floor--;//отнимаем этаж

cout << "\n Лифт спускается на " << floor << " этаж" << endl; // вывод информации в консоли

}

void Opendoor() {

// функция для открытия дверей лифта

door++; // открываем дверь

cout << "\n Лифт открывает двери" << endl;// вывод информации в консоли

}

void Closedoor() {

// функция для закрытия дверей лифта

door--; // закрываем дверь

cout << "\n Лифт закрывает двери" << endl; // вывод информации в консоли

}

void setButtonElevator(int p, bool set) {

/// функция для задания состояния кнопки в лифте

bt.setstatus(set, p);

}

void elevatorcall(int tofloor) {

// функция для вызова лифта к пассажиру

if (tofloor == floor) {

// Если нужный этаж равен этажу с лифтом

Opendoor(); // открываем двери

}

else if (tofloor > floor) {// если нужный этаж выше этажа с лифтом

while (tofloor != floor) { // поднимаем лифт, пока этажи не будут равными

up();

}

Opendoor();// открываем двери

}

else if (tofloor < floor)

{// если нужный этаж ниже этажа с лифтом

while (tofloor != floor) {// опускаем лифт, пока этажи не будут равными

down();

}

Opendoor();// открываем двери

}

}

void enterfloorButton(int p) {

// функция для передвижения лифта к заданному этажу пассажиром

if (p == floor) { // если пассажир и лифт на одном этаже

setButtonElevator(p, true);// включение кнопки

Sleep(3000); // пауза на 3 секунды

setButtonElevator(p, false);//выключение кнопки

}

else if (p < floor) { // если пассажир ниже лифта

setButtonElevator(p, true); // включение кнопки

Closedoor(); // закрытие дверей

while (p != floor) { /// опускаем лифт, пока этажи не будут равными

down();

}

Opendoor(); // открытие двери

setButtonElevator(p, false); //выключение двери

}

else if (p > floor) { // если пассажир выше лифта

setButtonElevator(p, true); // включение кнопки

Closedoor(); // закрытие дверей

while (p != floor) {// поднимаем лифт, пока этажи не будут равными

up();

}

Opendoor();// открытие дверей

setButtonElevator(p, false); // выключение кнопки

}

}

void showstatus(int fl) { bt.showstatus(fl); } // функция для отображения состояния кнопки в лифте

void setstatus(bool p, int fl) { bt.setstatus(p, fl); } // функция для задания состояния кнопки в лифте


};

ПРИЛОЖЕНИЕ Г

Листинг класса MyForm.

#pragma once

// подключение заголовочных файлов

#include <windows.h>

#include <iostream>

#include <string>

#include <time.h>

#include "button.h"

#include "elevator.h"

#include "man.h"

using namespace std; //объявление пространства имен std

// пространство имен lift

namespace Lift {

// объявление пространства имен

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

/// <summary>

/// Сводка для MyForm

/// </summary>

// класс формы Myform

public ref class MyForm : public System::Windows::Forms::Form

{

public: // объявление видимых переменных в классе

int MainNumberFloor, MainNumberPassenger;

int PassengerTime, ButtonTime, LiftTime, DoorTime;

public:

// конструктор класса

MyForm(void)

{

InitializeComponent(); // инициализирует все компоненты, расположенные на форме

this->SetStyle(ControlStyles::SupportsTransparentBackColor, true);

}

protected:

/// <summary>

/// Освободить все используемые ресурсы.

/// </summary>

//деструктор класса

~MyForm()

{//удаление компонентов, если они есть

if (components)

{

delete components;

}

}

// объявление компонентов формы

private: System::Windows::Forms::PictureBox^ pictureBox14;

private: System::Windows::Forms::PictureBox^ pictureBox15;

private: System::Windows::Forms::Label^ label6;

private: System::Windows::Forms::Label^ label7;

private: System::Windows::Forms::GroupBox^ groupBox1;

private: System::Windows::Forms::TextBox^ textBox6;

private: System::Windows::Forms::Label^ label11;

private: System::Windows::Forms::TextBox^ textBox5;

private: System::Windows::Forms::Label^ label10;

private: System::Windows::Forms::TextBox^ textBox4;

private: System::Windows::Forms::Label^ label9;

private: System::Windows::Forms::TextBox^ textBox3;

private: System::Windows::Forms::Label^ label8;

private: System::Windows::Forms::PictureBox^ pictureBox13;

private: System::Windows::Forms::Button^ button1;

private: System::ComponentModel::BackgroundWorker^ backgroundWorker1;

private: System::Windows::Forms::PictureBox^ pictureBox1;

private: System::Windows::Forms::PictureBox^ pictureBox2;

private: System::Windows::Forms::PictureBox^ pictureBox3;

private: System::Windows::Forms::Label^ label1;

private: System::Windows::Forms::Label^ label2;

private: System::Windows::Forms::TextBox^ textBox1;

private: System::Windows::Forms::Label^ label3;

private: System::Windows::Forms::PictureBox^ pictureBox4;

private: System::Windows::Forms::PictureBox^ pictureBox5;

private: System::Windows::Forms::PictureBox^ pictureBox6;

private: System::Windows::Forms::PictureBox^ pictureBox7;

private: System::Windows::Forms::PictureBox^ pictureBox8;

private: System::Windows::Forms::Label^ label4;

private: System::Windows::Forms::PictureBox^ pictureBox9;

private: System::Windows::Forms::PictureBox^ pictureBox10;

private: System::Windows::Forms::PictureBox^ pictureBox11;

private: System::Windows::Forms::PictureBox^ pictureBox12;

private: System::Windows::Forms::Label^ label5;

private: System::Windows::Forms::TextBox^ textBox2;

protected:

private:

/// <summary>

/// Обязательная переменная конструктора.

/// </summary>

System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code

/// <summary>


/// Требуемый метод для поддержки конструктора — не изменяйте

/// содержимое этого метода с помощью редактора кода.

/// </summary>

// метод инциализации компонентов

void InitializeComponent(void)

{

System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));

this->button1 = (gcnew System::Windows::Forms::Button());

this->backgroundWorker1 = (gcnew System::ComponentModel::BackgroundWorker());

this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox2 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox3 = (gcnew System::Windows::Forms::PictureBox());

this->label1 = (gcnew System::Windows::Forms::Label());

this->label2 = (gcnew System::Windows::Forms::Label());

this->textBox1 = (gcnew System::Windows::Forms::TextBox());

this->label3 = (gcnew System::Windows::Forms::Label());

this->pictureBox4 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox5 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox6 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox7 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox8 = (gcnew System::Windows::Forms::PictureBox());

this->label4 = (gcnew System::Windows::Forms::Label());

this->pictureBox9 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox10 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox11 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox12 = (gcnew System::Windows::Forms::PictureBox());

this->label5 = (gcnew System::Windows::Forms::Label());

this->textBox2 = (gcnew System::Windows::Forms::TextBox());

this->pictureBox13 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox14 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox15 = (gcnew System::Windows::Forms::PictureBox());

this->label6 = (gcnew System::Windows::Forms::Label());

this->label7 = (gcnew System::Windows::Forms::Label());

this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());

this->textBox6 = (gcnew System::Windows::Forms::TextBox());

this->label11 = (gcnew System::Windows::Forms::Label());

this->textBox5 = (gcnew System::Windows::Forms::TextBox());

this->label10 = (gcnew System::Windows::Forms::Label());

this->textBox4 = (gcnew System::Windows::Forms::TextBox());

this->label9 = (gcnew System::Windows::Forms::Label());

this->textBox3 = (gcnew System::Windows::Forms::TextBox());

this->label8 = (gcnew System::Windows::Forms::Label());

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox2))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox3))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox4))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox5))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox6))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox7))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox8))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox9))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox10))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox11))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox12))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox13))->BeginInit();


(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox14))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox15))->BeginInit();

this->groupBox1->SuspendLayout();

this->SuspendLayout();

//

// button1

//

this->button1->Location = System::Drawing::Point(30, 121);

this->button1->Name = L"button1";

this->button1->Size = System::Drawing::Size(75, 23);

this->button1->TabIndex = 0;

this->button1->Text = L"Запуск";

this->button1->UseVisualStyleBackColor = true;

this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);

//

// backgroundWorker1

//

this->backgroundWorker1->DoWork += gcnew System::ComponentModel::DoWorkEventHandler(this, &MyForm::backgroundWorker1_DoWork);

//

// pictureBox1

//

this->pictureBox1->BackColor = System::Drawing::Color::Transparent;

this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox1.Image")));

this->pictureBox1->InitialImage = nullptr;

this->pictureBox1->Location = System::Drawing::Point(247, 316);

this->pictureBox1->Name = L"pictureBox1";

this->pictureBox1->Size = System::Drawing::Size(38, 72);

this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::Zoom;

this->pictureBox1->TabIndex = 1;

this->pictureBox1->TabStop = false;

//

// pictureBox2

//

this->pictureBox2->BackColor = System::Drawing::Color::Transparent;

this->pictureBox2->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox2.Image")));

this->pictureBox2->Location = System::Drawing::Point(208, 229);

this->pictureBox2->Name = L"pictureBox2";

this->pictureBox2->Size = System::Drawing::Size(118, 81);

this->pictureBox2->SizeMode = System::Windows::Forms::PictureBoxSizeMode::Zoom;

this->pictureBox2->TabIndex = 2;

this->pictureBox2->TabStop = false;

//

// pictureBox3

//

this->pictureBox3->BackColor = System::Drawing::Color::Transparent;

this->pictureBox3->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox3.Image")));

this->pictureBox3->Location = System::Drawing::Point(235, 171);

this->pictureBox3->Name = L"pictureBox3";

this->pictureBox3->Size = System::Drawing::Size(75, 52);

this->pictureBox3->SizeMode = System::Windows::Forms::PictureBoxSizeMode::Zoom;

this->pictureBox3->TabIndex = 3;

this->pictureBox3->TabStop = false;

//

// label1

//

this->label1->AutoSize = true;

this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label1->Location = System::Drawing::Point(260, 188);

this->label1->Name = L"label1";

this->label1->Size = System::Drawing::Size(57, 20);

this->label1->TabIndex = 4;

this->label1->Text = L"label1";

//

// label2

//

this->label2->AutoSize = true;

this->label2->Location = System::Drawing::Point(13, 16);

this->label2->Name = L"label2";

this->label2->Size = System::Drawing::Size(138, 13);

this->label2->TabIndex = 5;

this->label2->Text = L"Количество этажей в дом";

//

// textBox1

//

this->textBox1->Location = System::Drawing::Point(172, 13);

this->textBox1->Name = L"textBox1";

this->textBox1->Size = System::Drawing::Size(100, 20);

this->textBox1->TabIndex = 6;

//

// label3

//

this->label3->AutoSize = true;

this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label3->Location = System::Drawing::Point(52, 188);


this->label3->Name = L"label3";

this->label3->Size = System::Drawing::Size(57, 20);

this->label3->TabIndex = 8;

this->label3->Text = L"label3";

//

// pictureBox4

//

this->pictureBox4->BackColor = System::Drawing::Color::Transparent;

this->pictureBox4->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox4.Image")));

this->pictureBox4->Location = System::Drawing::Point(30, 171);

this->pictureBox4->Name = L"pictureBox4";

this->pictureBox4->Size = System::Drawing::Size(75, 52);

this->pictureBox4->SizeMode = System::Windows::Forms::PictureBoxSizeMode::Zoom;

this->pictureBox4->TabIndex = 7;

this->pictureBox4->TabStop = false;

//

// pictureBox5

//

this->pictureBox5->BackColor = System::Drawing::Color::Transparent;

this->pictureBox5->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox5.Image")));

this->pictureBox5->Location = System::Drawing::Point(30, 238);

this->pictureBox5->Name = L"pictureBox5";

this->pictureBox5->Size = System::Drawing::Size(80, 50);

this->pictureBox5->SizeMode = System::Windows::Forms::PictureBoxSizeMode::Zoom;

this->pictureBox5->TabIndex = 9;

this->pictureBox5->TabStop = false;

//

// pictureBox6

//

this->pictureBox6->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox6.Image")));

this->pictureBox6->Location = System::Drawing::Point(30, 238);

this->pictureBox6->Margin = System::Windows::Forms::Padding(0);

this->pictureBox6->Name = L"pictureBox6";

this->pictureBox6->Size = System::Drawing::Size(80, 50);

this->pictureBox6->SizeMode = System::Windows::Forms::PictureBoxSizeMode::Zoom;

this->pictureBox6->TabIndex = 10;

this->pictureBox6->TabStop = false;

//

// pictureBox7

//

this->pictureBox7->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox7.Image")));

this->pictureBox7->Location = System::Drawing::Point(402, 238);

this->pictureBox7->Name = L"pictureBox7";

this->pictureBox7->Size = System::Drawing::Size(79, 50);

this->pictureBox7->SizeMode = System::Windows::Forms::PictureBoxSizeMode::Zoom;

this->pictureBox7->TabIndex = 11;

this->pictureBox7->TabStop = false;

//

// pictureBox8

//

this->pictureBox8->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox8.Image")));

this->pictureBox8->Location = System::Drawing::Point(402, 238);

this->pictureBox8->Name = L"pictureBox8";

this->pictureBox8->Size = System::Drawing::Size(79, 50);

this->pictureBox8->SizeMode = System::Windows::Forms::PictureBoxSizeMode::Zoom;

this->pictureBox8->TabIndex = 12;

this->pictureBox8->TabStop = false;

//

// label4

//

this->label4->AutoSize = true;

this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label4->Location = System::Drawing::Point(430, 251);

this->label4->Name = L"label4";

this->label4->Size = System::Drawing::Size(57, 20);

this->label4->TabIndex = 13;

this->label4->Text = L"label4";

//

// pictureBox9

//

this->pictureBox9->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox9.Image")));

this->pictureBox9->Location = System::Drawing::Point(208, 229);

this->pictureBox9->Name = L"pictureBox9";

this->pictureBox9->Size = System::Drawing::Size(59, 81);

this->pictureBox9->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage;

this->pictureBox9->TabIndex = 14;

this->pictureBox9->TabStop = false;

//

// pictureBox10

//

this->pictureBox10->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox10.Image")));