Добавил:
Рад, если кому-то помог Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
0
Добавлен:
01.11.2025
Размер:
2.99 Кб
Скачать
#include <iostream>
#include <string>
#include <locale>
using namespace std;

class Window {
protected:
    string title;
    int x, y, width, height;
public:
    Window(const string& t, int x_pos, int y_pos, int w, int h) 
        : title(t), x(x_pos), y(y_pos), width(w), height(h) {}
    
    virtual void display() const {
        cout << "Окно \"" << title << "\" в (" << x << ", " << y 
             << ") размером " << width << "x" << height << endl;
    }
    
    virtual void close() {
        cout << "Закрываем окно \"" << title << "\"" << endl;
    }
    
    virtual ~Window() {}
};

class StackWindow : public Window {
    int zIndex;
public:
    StackWindow(const string& t, int x_pos, int y_pos, int w, int h, int z) 
        : Window(t, x_pos, y_pos, w, h), zIndex(z) {}
    
    void display() const override {
        cout << "Стековое окно \"" << title << "\" (z-index: " << zIndex 
             << ") в (" << x << ", " << y << ")" << endl;
    }
    
    void bringToFront() {
        zIndex = 1000; // Максимальный приоритет
        cout << "Окно \"" << title << "\" перемещено на передний план" << endl;
    }
};

class LayeredWindow : public Window {
    double opacity;
public:
    LayeredWindow(const string& t, int x_pos, int y_pos, int w, int h, double op) 
        : Window(t, x_pos, y_pos, w, h), opacity(op) {}
    
    void display() const override {
        cout << "Слоёное окно \"" << title << "\" (прозрачность: " << opacity 
             << ") в (" << x << ", " << y << ")" << endl;
    }
    
    void setOpacity(double op) {
        opacity = op;
        cout << "Прозрачность окна \"" << title << "\" установлена в " << opacity << endl;
    }
};

class PopupWindow : public Window {
    int timeout;
public:
    PopupWindow(const string& t, int x_pos, int y_pos, int w, int h, int t_out) 
        : Window(t, x_pos, y_pos, w, h), timeout(t_out) {}
    
    void display() const override {
        cout << "Всплывающее окно \"" << title << "\" (таймаут: " << timeout 
             << "ms) в (" << x << ", " << y << ")" << endl;
    }
    
    void autoClose() {
        cout << "Окно \"" << title << "\" закроется автоматически через " << timeout << "ms" << endl;
    }
};

int main() {
    setlocale(LC_ALL, "ru_RU.UTF-8");
    
    StackWindow stackWin("Документ", 100, 100, 800, 600, 1);
    LayeredWindow layeredWin("Панель инструментов", 0, 0, 200, 400, 0.8);
    PopupWindow popupWin("Уведомление", 300, 200, 400, 200, 5000);
    
    stackWin.display();
    layeredWin.display();
    popupWin.display();
    
    stackWin.bringToFront();
    layeredWin.setOpacity(0.5);
    popupWin.autoClose();
    
    return 0;
}
Соседние файлы в папке Лаба5