Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- using namespace std;
- class Abonat
- {
- public:
- Abonat(void); // по подразбиране;
- Abonat(string, string, int, int, double); // за инициализиране
- ~Abonat();
- void Printirane(void);
- void IzchisliSrednaProduljitelnost();
- protected:
- string nomer;
- string imeSobstvenik;
- int broiRazgovori;
- int produljitelnostRazgovori;
- double duljimaSuma;
- double srednaProduljitelnost = 0; // за IzchisliSrednaProduljitelnost
- };
- int main()
- {
- /*Abonat abonat1("0891234567", "Pavel", 100, 2000, 30.45);
- abonat1.IzchisliSrednaProduljitelnost();
- abonat1.Printirane();*/
- Abonat *abonati[6];
- Abonat *a = new Abonat("0891234561", "Pavel1", 100, 1000, 10.45);
- Abonat *b = new Abonat("0891234562", "Pavel2", 100, 2000, 20.45);
- Abonat *c = new Abonat("0891234563", "Pavel3", 100, 3000, 30.45);
- Abonat* d = new Abonat("0891234564", "Pavel4", 100, 4000, 40.45);
- Abonat* e = new Abonat("0891234565", "Pavel5", 100, 5000, 50.45);
- Abonat* f = new Abonat("0891234566", "Pavel6", 100, 6000, 60.45);
- abonati[0] = a;
- abonati[1] = b;
- abonati[2] = c;
- abonati[3] = d;
- abonati[4] = e;
- abonati[5] = f;
- for (int i = 0; i < 6; i++)
- {
- abonati[i]->IzchisliSrednaProduljitelnost();
- abonati[i]->Printirane();
- }
- }
- Abonat :: Abonat(void)
- {
- }
- Abonat :: Abonat(string nomerInput, string imeSobstvenikInput, int broiRazgovoriInput, int produljitelnostRazgovoriInput
- , double duljimaSumaInput)
- {
- nomer = nomerInput;
- imeSobstvenik = imeSobstvenikInput;
- broiRazgovori = broiRazgovoriInput;
- produljitelnostRazgovori = produljitelnostRazgovoriInput;
- duljimaSuma = duljimaSumaInput;
- }
- Abonat :: ~Abonat()
- {
- }
- void Abonat::Printirane()
- {
- cout << nomer << endl << imeSobstvenik << endl <<
- broiRazgovori << endl << produljitelnostRazgovori << endl << duljimaSuma << endl
- <<
- "Sredna produljitelnost na razgovor: " << srednaProduljitelnost << " sec" << endl;
- cout << "-------------------------------------" << endl;
- }
- void Abonat::IzchisliSrednaProduljitelnost()
- {
- srednaProduljitelnost = produljitelnostRazgovori / broiRazgovori;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement