Создание приложения для создания геометрических фигур
Создание Windows-приложения для построения геометрических фигур и графиков функций, которое предлагает пользователю ввести данные начала промежутка, конца промежутка и шага изменения переменной, осуществление проверки правильности ввода данных.
| Рубрика | Программирование, компьютеры и кибернетика |
| Вид | лабораторная работа |
| Язык | русский |
| Дата добавления | 08.11.2024 |
| Размер файла | 326,5 K |
Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже
Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.
Размещено на http://www.allbest.ru/
Ташкентский университет информационных технологий
Факультет Программного Инжиниринга
Отчёт
По лабораторной работе
Дисциплины “Программирование”
Выполнил:
Студент группы PRG204-1
Марксов Нурисломбек
Ташкент 2024
1. Создать Windows-приложение для построения геометрических фигур и графиков функций, которое предлагает пользователю ввести данные начала промежутка (xn), конца промежутка (xk) и шага изменения переменной (xh) (сделать проверку правильности ввода данных).
приложение геометрический пользователь данные
A)
#pragma once
namespace dedline {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public ref class Form1: public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
shouldDraw = false; // Initialize the flag to false
}
protected:
~Form1()
{
if (components)
{
delete components;
}
}
private:
System::Windows::Forms::Label^ label1;
System::Windows::Forms::Button^ button1;
bool shouldDraw; // Flag to control drawing
private:
System::ComponentModel::Container^ components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->label1 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(719, 503);
this->label1->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(44, 16);
this->label1->TabIndex = 0;
this->label1->Text = L"label1";
//
// button1
//
this->button1->Font = (gcnew System::Drawing::Font(L"Times New Roman", 13.8F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->button1->Location = System::Drawing::Point(781, 489);
this->button1->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(168, 39);
this->button1->TabIndex = 1;
this->button1->Text = L"Старт";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(1080, 578);
this->Controls->Add(this->button1);
this->Controls->Add(this->label1);
this->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
this->Name = L"Form1";
this->Text = L"\"Выполнил студент группы PRG-204 Марсов Нурислом\"";
this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::Form1_Paint);
this->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::Form1_MouseMove);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private:
System::Void Form1_MouseMove(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
label1->Text = e->X + "," + e->Y;
}
System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
shouldDraw = true; // Set the flag to true when button is clicked
this->Invalidate(); // Redraw the form
}
System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
if (shouldDraw) { // Check the flag before drawing
Graphics^ g = e->Graphics; //Define pens and brushes
SolidBrush^ grayBrush = gcnew SolidBrush(Color::Gray); // Серый цвет для заливки прямоугольника и круга
Pen^ circlePen = gcnew Pen(Color::Black, 2); // Черный цвет и толщина 2 для границы круга
Pen^ rectPen = gcnew Pen(Color::Black, 1); // Черный цвет и толщина 2 для границы прямоугольника
// Define the rectangle
int rectWidth = 100;
int rectHeight = 50;
int circleDiameter = 90;
// Центр круга
int circleCenterX = 150;
int circleCenterY = 150;
// Координаты верхнего левого угла прямоугольника
int rectX = circleCenterX - rectWidth / 2;
int rectY = circleCenterY - rectHeight / 2;
// Координаты верхнего левого угла круга
int circleX = circleCenterX - circleDiameter / 2;
int circleY = circleCenterY - circleDiameter / 2;
// Draw the filled circle
g->FillEllipse(grayBrush, circleX, circleY, circleDiameter, circleDiameter);
// Draw the border of the circle
g->DrawEllipse(circlePen, circleX, circleY, circleDiameter, circleDiameter);
// Draw the filled rectangle
g->FillRectangle(grayBrush, rectX, rectY, rectWidth, rectHeight);
// Draw the border of the rectangle
g->DrawRectangle(rectPen, rectX, rectY, rectWidth, rectHeight);
}
}
};
}
B)
#pragma once
#include "stdafx.h"
#include <iostream>
namespace WindowsFormsApplication5 {
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>
/// Summary for Form1
/// </summary>
public ref class Form1: public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::DataVisualization::Charting::Chart^ chart1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Button^ button1;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::Windows::Forms::DataVisualization::Charting::ChartArea^ chartArea1 = (gcnew System::Windows::Forms::DataVisualization::Charting::ChartArea());
System::Windows::Forms::DataVisualization::Charting::Legend^ legend1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Legend());
System::Windows::Forms::DataVisualization::Charting::Series^ series1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
System::Windows::Forms::DataVisualization::Charting::Title^ title1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Title());
this->chart1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Chart());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->label3 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->chart1))->BeginInit();
this->SuspendLayout();
//
// chart1
//
this->chart1->BackColor = System::Drawing::Color::Olive;
chartArea1->Name = L"ChartArea1";
this->chart1->ChartAreas->Add(chartArea1);
legend1->Name = L"Legend1";
this->chart1->Legends->Add(legend1);
this->chart1->Location = System::Drawing::Point(45, 60);
this->chart1->Name = L"chart1";
series1->BorderWidth = 5;
series1->ChartArea = L"ChartArea1";
series1->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Spline;
series1->Color = System::Drawing::Color::Red;
series1->LabelForeColor = System::Drawing::Color::Red;
series1->Legend = L"Legend1";
series1->Name = L"Series1";
series1->XValueType = System::Windows::Forms::DataVisualization::Charting::ChartValueType::Double;
series1->YValuesPerPoint = 4;
series1->YValueType = System::Windows::Forms::DataVisualization::Charting::ChartValueType::Double;
this->chart1->Series->Add(series1);
this->chart1->Size = System::Drawing::Size(443, 300);
this->chart1->TabIndex = 0;
this->chart1->Text = L"chart1";
title1->BackSecondaryColor = System::Drawing::Color::White;
title1->BorderColor = System::Drawing::Color::White;
title1->BorderWidth = 6;
title1->Name = L"funksiya grafika";
title1->Text = L"funksiya grafika";
this->chart1->Titles->Add(title1);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(551, 80);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(28, 17);
this->label1->TabIndex = 1;
this->label1->Text = L"a =";
this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(551, 141);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(32, 17);
this->label2->TabIndex = 2;
this->label2->Text = L"b = ";
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(680, 77);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(100, 22);
this->textBox1->TabIndex = 3;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(680, 141);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(100, 22);
this->textBox2->TabIndex = 4;
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(680, 209);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(100, 22);
this->textBox3->TabIndex = 5;
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(551, 209);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(46, 17);
this->label3->TabIndex = 6;
this->label3->Text = L"label3";
//
// button1
//
this->button1->Location = System::Drawing::Point(554, 274);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(214, 69);
this->button1->TabIndex = 7;
this->button1->Text = L"draw function\'s graphic";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(891, 514);
this->Controls->Add(this->button1);
this->Controls->Add(this->label3);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->chart1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->chart1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Double a,b, h,x,y;
a=Convert::ToDouble(textBox1->Text);
b=Convert::ToDouble(textBox2->Text);
h=Convert::ToDouble(textBox3->Text);
this->chart1->Series["Series1"]->Points->Clear();
x=a;
while(x<=b)
{ y=Math::Pow(x,4)+1;
this->chart1->Series["Series1"]->Points->AddXY(x,y);
x+=h;
}
}
};
}
Размещено на Allbest.ru
Подобные документы
Создание приложения, которое будет производить построение графиков функций по заданному математическому выражению. Разработка программы "Генератор математических функций". Создание мастера функций для ввода математического выражения, тестирование.
дипломная работа [1,7 M], добавлен 16.02.2016Построение системы классов для описания плоских геометрических фигур: круг, квадрат, прямоугольник. Методы для создания объектов, перемещения на плоскости, изменения размеров и вращения на заданный угол. Реализованные алгоритмы, тестирование программы.
курсовая работа [129,3 K], добавлен 04.05.2014Объектно-ориентированные возможности языка C++. Моделирование системы геометрических фигур, методика проектирования программных комплексов. Анализ предметной области, технология создания объектной модели. Упрощение классов при использовании наследования.
курсовая работа [668,8 K], добавлен 22.09.2011Разработка программы в Turbo C++ Explorer для вычислений геометрических данных фигуры. Атрибуты объекта и представление данных в программе. Подпрограмма создания набора данных. Реализация защиты и правильности ввода данных и дополнительных функции.
курсовая работа [5,9 M], добавлен 22.02.2014Разработка приложения для проверки использования времен глаголов в английском языке. Создание базы данных. Анализ используемых средств для реализации автоматического разбора текста. Проектирование мобильного приложения с помощью диаграмм деятельности.
дипломная работа [2,6 M], добавлен 13.09.2017Сущность основных понятий объектно-ориентированного программирования: объект, класс, полиморфизм. Блок-схема алгоритма и текст программы для вычисления площади круга, прямоугольника и трапеции. Принцип работы и результаты тестирования приложения.
курсовая работа [588,7 K], добавлен 17.07.2012Проектирование службы Windows и приложения для управления этой службой, которое позволит контролировать данные приложения - запускать и завершать определенные процессы по желанию пользователя через определенные промежутки времени. Инструкция по установке.
курсовая работа [2,8 M], добавлен 05.01.2013Описание платформы NET Framework. База данных Microsoft Access. Разработка Windows приложения. Модель программирования Windows Forms. Функциональное назначение программы. Входные и выходные данные. Требования к техническому и программному обеспечению.
курсовая работа [2,2 M], добавлен 15.03.2015Анализ предметной области, функциональные части и этапы создания web-приложения, которое будет осуществлять интернет-торговлю по схеме "Предприятие – клиенты". Разработка вспомогательного web-приложения, необходимое для работы с базой данных основного.
курсовая работа [3,3 M], добавлен 05.06.2011Разработка приложения, которое будет выполнять функции показа точного времени и точной даты. Определение дополнительных функций разработанного приложения. Рассмотрение основных этапов создания программного продукта. Результаты тестирования приложения.
курсовая работа [2,2 M], добавлен 14.04.2019
