帮我看下这个代码
#include <iostream>
using namespace std;
class Bottel
{
public:
Bottel(int capacity);
public:
void FlowOut(Bottel* odj);
int FlowIn(int Mete);
int getMete();
void Full();
private:
int maxCapa;
int theMete;
};
Bottel::Bottel(int capacity)
:maxCapa(capacity)
,theMete(0)
{
}
void Bottel::Full()
{
theMete = maxCapa;
}
int Bottel::getMete()
{
return theMete;
}
void Bottel::FlowOut(Bottel* obj)
{
theMete = obj->FlowIn(theMete);
}
int Bottel::FlowIn(int Mete)
{
if(theMete + Mete <= maxCapa)
{
theMete = theMete + Mete;
return 0;
}
else
{
int Return = theMete + Mete - maxCapa;
theMete = maxCapa;
return Return;
}
}
int main()
{
Bottel* BArr[3];
BArr[0] = new Bottel(7);
BArr[1] = new Bottel(3);
BArr[2] = new Bottel(10);
BArr[2]->Full();
int i = 0;
int tenMete = 0;
int sevMete = 0;
while(tenMete!=5)
{
if(sevMete!=5)
{
BArr[2]->FlowOut(BArr[0]);
sevMete = BArr[0]->getMete();
}
else
{
BArr[1]->FlowOut(BArr[2]);
tenMete = BArr[2]->getMete();
}
i = 0;
while(sevMete!=0 && sevMete!=5)
{
BArr[i]->FlowOut(BArr[i+1]);
tenMete = BArr[2]->getMete();
sevMete = BArr[0]->getMete();
i=(i+1)%2;
}
}
return 0;
}