Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <string>
- using namespace std;
- class Animal {
- private:
- string pet, name;
- char sex;
- int price;
- int id;
- static int quantity;
- int set_id() {
- }
- public:
- Animal(string pet, string nzame, char sex, int price)
- {
- this->name = name;
- this->pet = pet;
- if (sex == 'm' || sex == 'f') {
- this->sex = sex;
- }
- else {
- while (sex != 'm' && sex != 'f') {
- cout <<"sex did not recognize, please try again:" << endl;
- cin >> sex;
- }
- this -> sex = sex;
- }
- this->price = price;
- quantity += 1;
- id = quantity - 1;
- }
- ~Animal(){}
- string get_sex() {
- if (this->sex == 'm')
- {
- return "male";
- }
- else if (this->sex == 'f') {
- return "female";
- }
- }
- int get_quantity() {
- return this->quantity;
- }
- };
- int Animal::quantity = 0;
- int main()
- {
- Animal cat("cat", "kit", 'f', 2100);
- Animal dog("d", "d", 'f', 2);
- cout << cat.get_quantity();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement