#include<cstring>
#include<string>
#include<conio.h>
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
#include<queue>
#include <algorithm>
#include<locale>
#include<ctime>
#include<Windows.h>
#include<string.h>
#include<stdlib.h>
#pragma warning (disable: 4996)
//Класс меню
class Menu {
protected:
int count; //количество команд
int active; //номер активной команды
char** command; //название команды
public:
//конструктор
Menu(int count, int active, char** command)
{
this->count = count;
this->active = active;
this->command = new char* [count];
for (int i = 0; i < count; i++)
{
this->command[i] = new char[20];
strcpy_s(this->command[i], 20, command[i]);
}
}
Menu() {
count = 0;
active = 0;
command = NULL;
};
//конструктор копирования
Menu(Menu& m)
{
count = m.count;
active = m.active;
protected:
char* title; //Заголовок
public:
//конструктор
Window(char* title, rectangle r, Menu m) : rectangle(r), Menu(m)
{
this->title = new char[100];
strcpy_s(this->title, 100, title);
}
//конструктор копирования
Window(const Window& w)
{
//rectangle
x1 = w.x1;
y1 = w.y1;
x2 = w.x2;
y2 = w.y2;
color = w.color;
//Menu
count = w.count;
active = w.active;
command = new char* [w.count];
for (int i = 0; i < count; i++)
{
command[i] = new char[20];
strcpy_s(command[i], 20, w.command[i]);
}
//Window
title = w.title;
}
//деструктор
~Window()
{
delete[] title;
}
return Window();
}
void print(ofstream& f)
{
f << title << '\n';
}
void print() {
//printf("\t%-25s%-11s% 8s", title);
Window();
}
};
class Queue {
protected:
queue<Window> q;
public:
void Print();
void Load();
void Save();
void Add();
void Edit();
void Del();
void Find();
};
void Queue::Print()
{
//queue <osoba>::iterator it;
int i = 0;
cout << "# Окно\n";
cout <<
"-------------------------------------------------------------------\n";
//it=os.begin();
int n = q.size();
queue <Window> t = q;
while (!t.empty())
{
cout << ++i;
t.front().print();
t.pop();
}
}
void Queue::Load()
{
char sn[5] = "";
int n = 0;
Window dd;
void Queue::Save()
{
ofstream f("text.txt", ios::out); //ff.close();
f << q.size() << '\n';
queue<Window> t = q;
while (!t.empty())
{
t.front().print(f);
t.pop();
}
f.close();
}
void Queue::Edit()//
{
int i = 0, n;
Print();
cout << "Введите номер редактируемоо элемента > ";
cin >> n;
if (n < 1 || n > q.size())
{
fprintf(stderr, "Элемент с номером %d не существует\n", n); return;
}
n--;
queue<Window> f, f2;
Window dd;
while (i < n)
{
f.push(q.front());
q.pop();
i++;
//f.back().print();
}
dd = q.front();
q.pop();
dd.set();
while (!q.empty())
{
f2.push(q.front());
q.pop();
}
while (!f.empty())
{
q.push(f.front());
f.pop();
}
q.push(dd);
while (!f2.empty())
{
q.push(f2.front());
f2.pop();
}
}
q.pop();
while (!q.empty())
{
f2.push(q.front());
q.pop();
}
while (!f.empty())
{
q.push(f.front());
f.pop();
}
while (!f2.empty())
{
q.push(f2.front());
f2.pop();
}
}
void Queue::Find()
{
int i = 0;
char str[50];
Print();
cout << "Введите Фамилию> ";
cin >> str;
queue<Window> f = q;
while (!f.empty())
{
if (strstr(f.front().getname(), str))
{
f.front().print(); i++;
}
f.pop();
void main()
{
Queue os;
int k;
setlocale(LC_ALL, "Russian");
/* char command[][6] = { "Add", "Save", "Load", "Print", "Find",
"Del","Edit" };
while ((k = men()) != 0 && k != 20)
switch (k)
{
case'1': os.Add(); break;
case'2': os.Save(); break;
case'3': os.Load(); break;
case'4': os.Print(); break;
case'5': os.Find(); break;
case'6': os.Del(); break;
case'7': os.Edit(); break;
}*/
while (true) {
cout << "[1] - Add\n[2] - Save\n[3] - Load\n[4] - Print\n[5] - Find\
n[6] - Del\n[7] - Edit\n[0] - Exit\n";
cin >> k;
switch (k)
{
case 1:
os.Add(); break;
break;
case 2:
os.Save(); break;
break;
case 3:
os.Load(); break;
case 4:
os.Print(); break;
break;
case 5:
os.Find(); break;
break;
case 6:
os.Del(); break;
case 7:
os.Edit(); break;
default:
cout << "Command not found!" << endl;
break;
}
}
/*rectangle f(1, 1, 80, 25, 2);
cout << "Склад объекта rectangle\n" << f;
system("pause");
}