#include <iostream>
#include <string>
using namespace std;

class CPU
{
public:
    CPU(float freq, float price);
    void upgradeCPU();
    void printCPUInfo();
private:
    float CPU_Frequency;
    float CPU_price;
};

class HDD
{
public:
    HDD(int size, float price);
    void upgradeHDD();
    void printHDDInfo();
private:
    int HDD_size;
    float HDD_price;
};

class MEM
{
public:
    MEM(int size, float price);
    void upgradeMEM();
    void printMEMInfo();
private:
    int MEM_size;
    float MEM_price;
};

class Computer : public HDD, public CPU, public MEM
{
public:
    Computer(string b, float cf, float cp, int hs, float hp, int ms, float mp);
    void upgrade();
    void printInfo();
private:
    string brand;
};


//-----------
CPU::CPU(float freq, float price)
    : CPU_Frequency(freq)
    , CPU_price(price)
{
}
HDD::HDD(int size, float price)
    : HDD_size(size)
    , HDD_price(price)
{
}
MEM::MEM(int size, float price)
    : MEM_size(size)
    , MEM_price(price)
{
}
Computer::Computer(string b, float cf, float cp, int hs, float hp, int ms, float mp)
    : CPU(cf, cp)
    , HDD(hs, hp)
    , MEM(ms, mp)
    , brand(b)
{
}


void CPU::printCPUInfo()
{
    cout << "CPU: " << CPU_Frequency << "Ghz, Price: $" << CPU_price;
}
void HDD::printHDDInfo()
{
    cout << "HDD: " << HDD_size << "GB, Price: $" << HDD_price;
}
void MEM::printMEMInfo()
{
    cout << "MEM: " << MEM_size << "GB, Price: $" << MEM_price;
}
void Computer::printInfo()
{
    cout << "brand: " << brand << ", ";
    printCPUInfo(); 
    cout << ", ";
    printHDDInfo();
    cout << ", ";
    printMEMInfo();
    cout << endl;
}


void CPU::upgradeCPU()
{
    CPU_Frequency += CPU_Frequency * 0.4f;
    CPU_price += CPU_price * 0.2f;
}
void HDD::upgradeHDD()
{
    HDD_size += HDD_size *0.5f;
    HDD_price += HDD_price *0.4f;
}
void MEM::upgradeMEM()
{
    MEM_size += MEM_size;
    MEM_price += MEM_price *0.8f;
}
void Computer::upgrade()
{
    upgradeCPU();
    upgradeHDD();
    upgradeMEM();
}

int main()
{
    Computer c("apple", 2.5, 100, 256, 50, 8, 60);
    c.printInfo();

    c.upgrade();
    c.printInfo();

    return 0;
}