36 lines
666 B
C++
36 lines
666 B
C++
#include <iostream>
|
|
|
|
class Animal
|
|
{
|
|
private:
|
|
int food;
|
|
int weight;
|
|
|
|
public:
|
|
void setAnimal(int _food, int _weight)
|
|
{
|
|
food = _food;
|
|
weight = _weight;
|
|
}
|
|
void increaseFood(int inc)
|
|
{
|
|
food += inc;
|
|
weight += inc / 3;
|
|
}
|
|
void viewStat()
|
|
{
|
|
std::cout << "이 동물의 Food : " << food << std::endl;
|
|
std::cout << "이 동물의 Weight : " << weight << std::endl;
|
|
}
|
|
};
|
|
|
|
int main()
|
|
{
|
|
Animal animal;
|
|
animal.setAnimal(100, 50);
|
|
animal.increaseFood(30);
|
|
|
|
animal.viewStat();
|
|
|
|
return 0;
|
|
} |