- //
- // main.cpp
- // Strumienie
- //
- // Created by Jakub Mirota on 07.05.2012.
- // Copyright (c) 2012 mirota.jakub@gmail.com. All rights reserved.
- //
- #include <iostream>
- #include <string>
- #include <iomanip>
- #include <fstream>
- #include <time.h>
- using namespace std;
- class Konta
- {
- string imie, nazwisko;
- char plec;
- int wiek;
- int nr_konta;
- int saldo_konta;
- public:
- Konta();
- Konta( string im, string naz, char p , int w, int nr):imie(im), nazwisko(naz), plec(p), wiek(w), nr_konta(nr)
- { saldo_konta = 0; cout << "Konstruktor argumentowy osoby"<< endl;} ;
- friend ostream & operator<<( ostream &scr, Konta &os);
- friend istream & operator>>( istream &scr, Konta &os);
- };
- ostream &zloty( ostream &ret);
- Konta::Konta()
- {
- cout << "Konstruktor bezargumentowy Osoby" << endl;
- }
- ostream &zloty( ostream &ret)
- {
- ret << " zł";
- return ret;
- }
- ostream & operator<<( ostream &src, Konta &os)
- {
- src << setfill( '=') << setw(30) << left << "Konto" << endl;
- src << "imie: " << setw(24) << setfill(' ') << right << os.imie << endl;
- src << "nazwisko: " << setw(20) << setfill(' ') << os.nazwisko << endl;
- if ( os.plec == 'M')
- {
- src << "plec: " << setw(24) << setfill(' ')<< "Mezczyzna" << endl;
- }
- else
- {
- src << "plec: " << setw(24) << setfill(' ') << "Kobieta" << endl;
- }
- src << "wiek: " << setw(24) << setfill(' ') << os.wiek << endl;
- src << "nr konta: " << setw(20) << setfill(' ') << os.nr_konta << endl;
- src << "saldo: " << setw(20) << setfill(' ') << os.saldo_konta << zloty << endl;
- src.fill('=');
- src.width(30);
- src << "" << endl;
- return src;
- }
- istream & operator >>( istream &scr, Konta &os)
- {
- cout << "Podaj imie: " << endl;
- scr >> os.imie;
- cout << "Podaj nazwisko: " << endl;
- scr >> os.nazwisko;
- cout << "Podaj plec( M lub K): " << endl;
- scr >> os.plec;
- cout << "Podaj wiek: " << endl;
- scr >> os.wiek;
- cout << "Podaj numer konta: " << endl;
- scr >> os.nr_konta;
- return scr;
- }
- int main()
- {
- srand ( time(NULL) );
- int a = rand()%1000+1;
- int b = rand()%1000+1;
- int c = rand()%1000+1;
- Konta os("Adam", "Jackiewicz", 'M', 20, a );
- Konta os2("Jan" , "Kowalski", 'M', 15,b);
- Konta os3("Janina", "Nowak", 'K', 35, c );
- Konta os4;
- cin >> os4;
- cout << os;
- cout << os2;
- cout << os3;
- cout << os4;
- ofstream out("strumienie.txt");
- out << os;
- out << os2;
- out << os3;
- out << os4;
- out.close();
- return 0;
- }