Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <string>
- #include <iomanip>
- using namespace std;
- class Human
- {
- public:
- int age;
- int length;
- int weight;
- string eyecolor;
- string name;
- void growOld();
- void exercise();
- void eatDoritos();
- void grow();
- };
- void Human::grow()
- {
- length++;
- }
- void Human::growOld()
- {
- age++;
- }
- void Human::exercise()
- {
- weight--;
- }
- void Human::eatDoritos()
- {
- weight++;
- }
- int main()
- {
- Human a;
- a.age = 17;
- a.length = 180;
- a.weight = 77;
- a.eyecolor = "Brown";
- a.name = "James";
- Human b;
- b.age = 45;
- b.length = 190;
- b.weight = 89;
- b.eyecolor = "Blue";
- b.name = "John";
- //Display of their characteristics
- cout << "Human A" << setw(10) << "Human B" << endl;
- cout << a.name << setw(8) << b.name << setw(10) << "Name" << endl;
- cout << a.age << setw(10) << b.age << setw(10) << "Age" << endl;
- cout << a.weight << setw(10) << b.weight << setw(10) << "\tWeight (kg)" << endl;
- cout << a.length << setw(10) << b.length << setw(10) << "\tLength (cm)" << endl;
- cout << a.eyecolor << setw(8) << b.eyecolor << setw(10) << "Eyecolor" << endl;
- //3 years passes by and human a as well as human b changes, both in shape and form. Who are they now?
- //Human a
- a.growOld();
- a.growOld();
- a.growOld();
- a.eatDoritos();
- a.eatDoritos();
- a.eatDoritos();
- a.eatDoritos();
- a.eatDoritos();
- a.grow();
- a.grow();
- a.grow();
- a.grow();
- //Human b
- b.growOld();
- b.growOld();
- b.growOld();
- b.exercise();
- b.exercise();
- b.exercise();
- b.exercise();
- b.exercise();
- b.exercise();
- b.grow();
- cout << "------------------" << endl;
- //Display of their characteristics
- cout << "Human A" << setw(10) << "Human B" << endl;
- cout << a.name << setw(8) << b.name << setw(10) << "Name" << endl;
- cout << a.age << setw(10) << b.age << setw(10) << "Age" << endl;
- cout << a.weight << setw(10) << b.weight << setw(10) << "\tWeight (kg)" << endl;
- cout << a.length << setw(10) << b.length << setw(10) << "\tLength (cm)" << endl;
- cout << a.eyecolor << setw(8) << b.eyecolor << setw(10) << "Eyecolor" << endl;
- int pause; cin >> pause; //Pause the program
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement