Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class pupil
- {
- public:
- int getage() {
- return age;
- }
- void AgeSet(int _age) {
- if (_age > 0 && _age < 100) {
- age = _age;
- cout << "Nice" << endl;
- }
- else {
- cout << "Error, your age can't be more than 100 years." << endl;
- }
- }
- void weightset(int _weight) {
- if (_weight > 0 && weight < 150) {
- weight = _weight;
- cout << "Nice" << endl;
- }
- else {
- cout << "Sorry, no. Error" << endl;
- }
- }
- private:
- string name;
- int age;
- int weight;
- };
- int main(){
- int age;
- cin >> age;
- int weight;
- cin >> weight;
- pupil pupil2;
- pupil2.AgeSet(age);
- pupil2.weightset(weight);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement