Created
January 8, 2026 12:48
-
-
Save m1irka/580edfa81a5d3e9e70433ab0cec34027 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> | |
| using namespace std; | |
| class Processor { | |
| const char* model; | |
| int cores; | |
| public: | |
| Processor(const char* m, int c) : model(m), cores(c) {} | |
| void show() { cout << "Processor: " << model << ", cores: " << cores << endl; } | |
| }; | |
| class RAM { | |
| int sizeGB; | |
| const char* type; | |
| public: | |
| RAM(int s, const char* t) : sizeGB(s), type(t) {} | |
| void show() { cout << "RAM: " << sizeGB << " GB, type: " << type << endl; } | |
| }; | |
| class Storage { | |
| int capacityGB; | |
| const char* type; | |
| public: | |
| Storage(int c, const char* t) : capacityGB(c), type(t) {} | |
| void show() { cout << "Storage: " << capacityGB << " GB, type: " << type << endl; } | |
| }; | |
| class Display { | |
| double sizeInches; | |
| const char* resolution; | |
| public: | |
| Display(double s, const char* r) : sizeInches(s), resolution(r) {} | |
| void show() { cout << "Display: " << sizeInches << " inches, resolution: " << resolution << endl; } | |
| }; | |
| class Keyboard { | |
| bool backlight; | |
| const char* layout; | |
| public: | |
| Keyboard(bool b, const char* l) : backlight(b), layout(l) {} | |
| void show() { cout << "Keyboard: layout " << layout << ", backlight: " << (backlight ? "Yes" : "No") << endl; } | |
| }; | |
| class Battery { | |
| int capacitymAh; | |
| int lifeHours; | |
| public: | |
| Battery(int c, int h) : capacitymAh(c), lifeHours(h) {} | |
| void show() { cout << "Battery: " << capacitymAh << " mAh, life: " << lifeHours << " hours" << endl; } | |
| }; | |
| class Touchpad { | |
| bool multiTouch; | |
| const char* type; | |
| public: | |
| Touchpad(bool m, const char* t) : multiTouch(m), type(t) {} | |
| void show() { cout << "Touchpad: " << type << ", multi-touch: " << (multiTouch ? "Yes" : "No") << endl; } | |
| }; | |
| class GPU { | |
| const char* model; | |
| int memoryGB; | |
| public: | |
| GPU(const char* m, int g) : model(m), memoryGB(g) {} | |
| void show() { cout << "GPU: " << model << ", memory: " << memoryGB << " GB" << endl; } | |
| }; | |
| class Laptop { | |
| Processor processor; | |
| RAM ram; | |
| Storage storage; | |
| Display display; | |
| Keyboard keyboard; | |
| Battery battery; | |
| Touchpad touchpad; | |
| GPU gpu; | |
| public: | |
| Laptop(Processor p, RAM r, Storage s, Display d, Keyboard k, Battery b, Touchpad t, GPU g) | |
| : processor(p), ram(r), storage(s), display(d), keyboard(k), battery(b), touchpad(t), gpu(g) { | |
| } | |
| void showSpecs() { | |
| processor.show(); | |
| ram.show(); | |
| storage.show(); | |
| display.show(); | |
| keyboard.show(); | |
| battery.show(); | |
| touchpad.show(); | |
| gpu.show(); | |
| } | |
| }; | |
| int main() { | |
| Processor p("Intel i7", 8); | |
| RAM r(16, "DDR4"); | |
| Storage s(512, "SSD"); | |
| Display d(15.6, "1920x1080"); | |
| Keyboard k(true, "QWERTY"); | |
| Battery b(6000, 8); | |
| Touchpad t(true, "Precision"); | |
| GPU g("NVIDIA GTX 1650", 4); | |
| Laptop laptop(p, r, s, d, k, b, t, g); | |
| laptop.showSpecs(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment