Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.8 kB
1
Indexable
Never
#include <iostream>
#include <string>
using namespace std;

class File {
protected:
    string name;
    int size;
    string dateOfCreation;
    string timeOfCreation;
    string attrib;
public:
    File() { //Конструктор за замовчуванням
        this->name = "";
        this->size = 0;
        this-> dateOfCreation = "dd.mm.yyyy";
        this->timeOfCreation = "hh.mm";
        this->attrib = "";
    }

    File(string name, int size, string dateOfCreation, string timeOfCreation, string attrib) { //Конструктор ініціалізації
        this->name = name;
        this->size = size;
        this->dateOfCreation = dateOfCreation;
        this->timeOfCreation = timeOfCreation;
        this->attrib = attrib;
    }

    void PrintInfo(string newname, int newsize, string newdateOfCreation, string newtimeOfCreation, string newattrib) //Метод
    {
        cout << "*File info*" << endl;
        cout << "Name: " << newname << endl;
        cout << "Size: " << newsize << endl;
        cout << "Date: " << newdateOfCreation << endl;
        cout << "Time: " << newtimeOfCreation << endl;
        cout << "Attribute: " << newattrib << endl;
    }


    ~File() = default;  //Деструктор

};

class Catalog: public File {
private:
    File* fileArray; //Агрегування
public:

    Catalog() { //Конструктор за замовчуванням
        this->fileArray = new File[this->size];
    }

    ~Catalog() = default;  //Деструктор
};

int main()
{
    string name;
    int size;
    string dateOfCreation;
    string timeOfCreation;
    string attrib;

    File file("file.txt", 2, "19.09.2022", "23:30", "p");
    file.PrintInfo(name, size, dateOfCreation, timeOfCreation, attrib);

    return 0;
}