Advertisement
PomozMi

Jipp 3

Sep 22nd, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. /*
  4. Seba Daniel Alex -> mistrz
  5. */
  6. using namespace std;
  7.  
  8. class Student
  9. {
  10. private:
  11.     int wiek;
  12.     string imie;
  13.     string nazwisko;
  14. public:
  15.     void pokaz(){
  16.         cout << endl << "imei:" << imie;
  17.         cout << endl << "nazw:" << nazwisko;
  18.         cout << endl << "wiek:" << wiek;
  19.     }
  20.     void setStudent(string  imie, string nazwisko, int wiek){
  21.         if (imie.length() == 0) throw "Nie podano imienia";  
  22.         else if (nazwisko.length() == 0) throw "Nie podano nazwiska";
  23.         else if (wiek <= 0)throw "zly wiek";//                  to jest ΕΊle
  24.         this->imie = imie;
  25.         this->nazwisko = nazwisko;
  26.         this->wiek = wiek;
  27.  
  28.     }
  29.  
  30. };
  31. int main(){
  32.  
  33.  
  34.     try{
  35.         Student studt;
  36.         studt.setStudent("Ziomeczek", "psikuta", 12);
  37.         studt.pokaz();
  38.         Student student;
  39.         student.setStudent("Arek", "To", "chuj");
  40.     }
  41.     catch (char *msg){ cout << msg; }
  42.     catch (...){}
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement