⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inwhere.cpp

📁 警察小偷爸爸妈妈儿子女儿过河
💻 CPP
字号:
// InWhere.cpp: implementation of the InWhere class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "River.h"
#include "InWhere.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

InWhere::InWhere()
{
	father = 1;
	mother = 1;
	plice = 1;
	son1 = 1;
	son2 = 1;
	daughter1 = 1;
	daughter2 = 1;
	shife = 1;
	

}

InWhere::~InWhere()
{

}

BOOL InWhere::Test()
{
	//测试符合场景状况的结点状态

	//必须要有个会驾船的和船在一边
	if(father !=boat && mother !=boat && plice !=boat)
		return FALSE;
	//如果有人在船上那么船必须为2
	//船上最多有2个人而且必须有个m_bCanDriver = TRUE的
	int i = 0;
	if(daughter1 == 2) i++;
	if(daughter2 == 2) i++;
	if(son1 == 2) i++;
	if(son2 == 2) i++;
	if(father == 2) i++;
	if(mother == 2) i++;
	if(plice == 2) i++;
	if(shife == 2) i++;
	if(i>2) return FALSE;
	if(i != 0 && boat != 2)
	return FALSE;
	//警察和小偷不在一起时候,小偷会伤害家人
	if(shife != plice)
	{
		if(daughter1 == shife || daughter2 == shife ||
			son1 == shife || son2 == shife ||
			father == shife || mother == shife)
		return FALSE;
	}

	//当爸爸妈妈不在一起时,妈妈骂儿子,爸爸骂女儿
	if(mother != father)
	{
		if(daughter1 == father || daughter2 == father ||
			son1 == mother || son2 == mother)
		return FALSE;
	}
	return TRUE;

}

InWhere & InWhere::operator =(const InWhere &other)
{
	daughter1 = other.daughter1;
	daughter2 = other.daughter2;
	father = other.father;
	mother = other.mother;
	plice = other.plice;
	shife = other.shife;
	son1 = other.son1;
	son2 = other.son2;
	boat = other.boat;
	return *this;
}

BOOL InWhere::operator ==(const InWhere &other)
{

	if(	daughter1 == other.daughter1 &&
	daughter2 == other.daughter2 &&
	father == other.father &&
	mother == other.mother &&
	plice == other.plice &&
	shife == other.shife &&
	son1 == other.son1 &&
	son2 == other.son2 && 
	boat == other.boat)
	return TRUE;
	
	return FALSE;
}

BOOL InWhere::operator !=(const InWhere &other)
{

	if(	daughter1 == other.daughter1 &&
		daughter2 == other.daughter2 &&
		father == other.father &&
		mother == other.mother &&
		plice == other.plice &&
		shife == other.shife &&
		son1 == other.son1 &&
		son2 == other.son2 && 
		boat == other.boat)
		return FALSE;

	return TRUE;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -