Created
April 1, 2026 18:18
-
-
Save m1irka/fe4332216e292e841d007ab5329dfe67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| using namespace std; | |
| class IDeviceinfo | |
| { | |
| public: | |
| virtual string GetName() = 0; | |
| virtual string GetSpecs() = 0; | |
| virtual ~IDeviceinfo() {} | |
| }; | |
| class VideoCard : public IDeviceinfo | |
| { | |
| public: | |
| string GetName() override { return "Video Card"; } | |
| string GetSpecs() override { return "NVIDIA RTX 4080, 16 GB"; } | |
| }; | |
| class CPU : public IDeviceinfo | |
| { | |
| string GetName() override { return "Processor"; } | |
| string GetSpecs() override { return "Intel Core i9-14900K, 24 cores"; } | |
| }; | |
| class HardGisk : public IDeviceinfo | |
| { | |
| string GetName() override { return "Hard Gisk"; } | |
| string GetSpecs() override { return"SSD 2TB, NVMe"; } | |
| }; | |
| class RAM : public IDeviceinfo | |
| { | |
| string GetName() override { return "RAM"; } | |
| string GetSpecs() override { return "DDR5, 32 GB, 6000MNz"; } | |
| }; | |
| class Report | |
| { | |
| protected: | |
| IDeviceinfo* device; | |
| public: | |
| Report(IDeviceinfo* dev): device(dev){} | |
| virtual void ShowReport() = 0; | |
| virtual ~Report(){} | |
| }; | |
| class DetailedReport : public Report { | |
| public: | |
| DetailedReport(IDeviceinfo* dev) : Report(dev) {} | |
| void ShowReport() override { cout << "[-----------------------------------------------]" << endl; | |
| cout << "Device: " << device->GetName() << "\n"; | |
| cout << "Specs: " << device->GetSpecs() << "\n"; | |
| } | |
| }; | |
| class ShortReport : public Report { | |
| public: | |
| ShortReport(IDeviceinfo* dev) : Report(dev) {} | |
| void ShowReport() override { | |
| //cout << "--------------Short Report---------------" << endl; | |
| cout << "Device: " << device->GetName() << "\n"; | |
| } | |
| }; | |
| int main() | |
| { | |
| IDeviceinfo* gpu = new VideoCard(); | |
| IDeviceinfo* cpu = new CPU(); | |
| IDeviceinfo* hg = new HardGisk(); | |
| IDeviceinfo* ram = new RAM(); | |
| Report* report1 = new DetailedReport(gpu); | |
| Report* report2 = new DetailedReport(cpu); | |
| Report* report3 = new DetailedReport(hg); | |
| Report* report4 = new DetailedReport(ram); | |
| report1->ShowReport(); | |
| report2->ShowReport(); | |
| report3->ShowReport(); | |
| report4->ShowReport(); | |
| delete gpu; | |
| delete cpu; | |
| delete hg; | |
| delete ram; | |
| delete report1; | |
| delete report2; | |
| delete report3; | |
| delete report4; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment