Skip to content

Instantly share code, notes, and snippets.

@XoLinA
Created April 2, 2026 19:41
Show Gist options
  • Select an option

  • Save XoLinA/f56e8a90fce5d1e63a6aac9a7ed4012e to your computer and use it in GitHub Desktop.

Select an option

Save XoLinA/f56e8a90fce5d1e63a6aac9a7ed4012e to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
using namespace std;
class IOutput abstract
{
public:
virtual void Print(string txt) abstract;
};
class ConsoleOutput:public IOutput
{
public:
void Print( string txt) { cout << txt<<endl; }
};
class DeviceReport abstract
{
protected:
IOutput* output;
public:
DeviceReport(IOutput* out):output(out){}
virtual void Show() abstract;
};
class VideoCard :public DeviceReport
{
public:
VideoCard(IOutput* out): DeviceReport(out){}
void Show()override
{
output->Print("Video Card: ");
output->Print("TTT 30303");
output->Print("50 GB");
cout << endl;
}
};
class CPU :public DeviceReport
{
public:
CPU(IOutput* out) : DeviceReport(out) {}
void Show()override
{
output->Print("CPU: ");
output->Print("Intel i9");
output->Print("8 cores");
cout << endl;
}
};
class HDD :public DeviceReport
{
public:
HDD(IOutput* out) : DeviceReport(out) {}
void Show()override
{
output->Print("HDD: ");
output->Print("1 TB SSD");
cout << endl;
}
};
class RAM :public DeviceReport
{
public:
RAM(IOutput* out) : DeviceReport(out) {}
void Show()override
{
output->Print("RAM: ");
output->Print("16 GB DDR4");
cout << endl;
}
};
int main()
{
IOutput* output = new ConsoleOutput();
DeviceReport* t1 = new VideoCard(output);
DeviceReport* t2 = new CPU(output);
DeviceReport* t3 = new HDD(output);
DeviceReport* t4 = new RAM(output);
t1->Show();
t2->Show();
t3->Show();
t4->Show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment