Last active
June 6, 2016 19:48
-
-
Save Soulstorm50/3e325f449b3caf1d254f88670982b25e to your computer and use it in GitHub Desktop.
Homework 1_1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Pet | |
{ | |
public: // модификатор доступа | |
char* type; //вид животного | |
char* name; // кличка | |
char* color; // цвет | |
int age; // возраст | |
double weight; //вес | |
bool is_hungry = false; //состояние(голоден или не голоден) | |
// методы: | |
void Play() | |
{ | |
cout << name << " is playing!\n"; | |
} | |
void Sleep() | |
{ | |
cout << name << " is sleep.\n"; | |
} | |
void Hunt() | |
{ | |
cout << name << " is hunting...\n"; | |
} | |
void Eat() | |
{ | |
if (is_hungry == true) | |
cout << name << " is eating\n"; | |
else | |
cout << name << " already eat\n"; | |
} | |
}; | |
void main() | |
{ | |
Pet dog; | |
dog.name = "Boss"; | |
dog.color = "Black"; | |
dog.type = "Dog"; | |
dog.weight = 15; | |
dog.Play(); | |
dog.Hunt(); | |
dog.Sleep(); | |
dog.Eat(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment