Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- class cPartycja
- {
- private:
- int Glowice;
- int RozmiarSektora; // B
- int RozmiarDyskuWSektorach;
- int Partycja[4];
- public:
- cPartycja(int glowice, int rozmiar_dysku_w_sektorach)
- {
- Glowice=glowice;
- RozmiarSektora=512;
- RozmiarDyskuWSektorach=rozmiar_dysku_w_sektorach;
- Partycja[0]=RozmiarDyskuWSektorach;
- Partycja[1]=0; Partycja[2]=0; Partycja[3]=0;
- }
- int getGlowice(){return Glowice;}
- int getPojemnoscSektory(){return RozmiarDyskuWSektorach;}
- int getPojemnoscKiB(){return RozmiarDyskuWSektorach*RozmiarSektora/1024;}
- int getSektor(){return RozmiarSektora;};
- void setSektor(int rozmiarsektora)
- {
- RozmiarSektora=rozmiarsektora;
- }
- int getPartycjaSektory(int partycja){return Partycja[partycja-1];}
- int getPartycjaKiB(int partycja){return (Partycja[partycja-1]*RozmiarSektora/1024);}
- bool Zwieksz(int partycja, int ile)
- {
- if(Partycja[partycja-2] >= ile)
- {
- Partycja[(partycja-2)]-=ile;
- Partycja[(partycja-1)]+=ile;
- return true;
- }
- return false;
- }
- bool Zmniejsz(int partycja, int ile)
- {
- if(Partycja[partycja-1] >= ile)
- {
- Partycja[partycja-2]+=ile;
- Partycja[partycja-1]-=ile;
- return true;
- }
- return false;
- }
- };
- int DrawMenu()
- {
- int Choosen;
- printf("1. Zwiekszenie partycji.\n");
- printf("2. Zmniejszenie partycji.\n");
- printf("0. Koniec programu.\n");
- printf("Wybieram: ");
- scanf("%d", &Choosen);
- return Choosen;
- }
- int WyborPartycji()
- {
- int Choosen;
- do
- {
- printf("\n Ktora partycja:");
- scanf("%d", &Choosen);
- } while( (Choosen<2) || (Choosen>4) );
- return Choosen;
- }
- int PobierzWielkosc()
- {
- int Wielkosc;
- do
- {
- printf("\n Ile sektorow:");
- scanf("%d", &Wielkosc);
- } while(Wielkosc<0);
- return Wielkosc;
- }
- int main(int argc, char *argv[])
- {
- cPartycja HDD(2, 1024);
- int Choosen;
- int Partycja;
- int Ile;
- do
- {
- system("CLS");
- printf("Rozmiar dysku: %-8d sekt. (%-6d KiB)\n", HDD.getPojemnoscSektory(), HDD.getPojemnoscKiB());
- for(int i=0; i<4; )
- {
- ++i;
- printf("Partycja %d: %-8d sekt. (%-6d KiB)\n", i, HDD.getPartycjaSektory(i), HDD.getPartycjaKiB(i));
- }
- printf("\n\n");
- Choosen=DrawMenu();
- switch(Choosen)
- {
- case 1:
- {
- Partycja=WyborPartycji();
- Ile=PobierzWielkosc();
- HDD.Zwieksz(Partycja, Ile);
- }
- break;
- case 2:
- {
- Partycja=WyborPartycji();
- Ile=PobierzWielkosc();
- HDD.Zmniejsz(Partycja, Ile);
- }
- break;
- }
- } while(Choosen!=0);
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement