Advertisement
MasterGun

Untitled

Mar 14th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. class pupil
  5. {
  6. public:
  7.     int getage() {
  8.  
  9.         return age;
  10.  
  11.     }
  12.     void AgeSet(int _age) {
  13.         if (_age > 0 && _age < 100) {
  14.  
  15.             age = _age;
  16.             cout << "Nice" << endl;
  17.         }
  18.         else {
  19.  
  20.             cout << "Error, your age can't be more than 100 years." << endl;
  21.  
  22.         }
  23.     }
  24.     void weightset(int _weight) {
  25.  
  26.         if (_weight > 0 && weight < 150) {
  27.  
  28.             weight = _weight;
  29.             cout << "Nice" << endl;
  30.  
  31.         }
  32.         else {
  33.  
  34.             cout << "Sorry, no. Error" << endl;
  35.  
  36.         }
  37.  
  38.     }
  39.  
  40. private:
  41.     string name;
  42.     int age;
  43.     int weight;
  44. };
  45. int main(){
  46.     int age;
  47.     cin >> age;
  48.     int weight;
  49.     cin >> weight;
  50.     pupil pupil2;
  51.     pupil2.AgeSet(age);
  52.     pupil2.weightset(weight);
  53.  
  54.  
  55. system("pause");
  56. return 0;
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement