parameter.cpp

来自「滑块问题求解系统:利用深度优先搜索和广度优先搜索解决有趣的滑块问题求解系统。」· C++ 代码 · 共 78 行

CPP
78
字号
// Parameter.cpp : 实现文件
//

#include "stdafx.h"
#include "AI.h"
#include "Parameter.h"
#include ".\parameter.h"


// CParameter 对话框

IMPLEMENT_DYNAMIC(CParameter, CDialog)
CParameter::CParameter(CWnd* pParent /*=NULL*/)
	: CDialog(CParameter::IDD, pParent)
	, her(1)
	, sleep(500)
	, maxstep(25)
{
}

CParameter::~CParameter()
{
}

void CParameter::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_HER, her);
	DDX_Text(pDX, IDC_SLEEP, sleep);
	DDX_Text(pDX, IDC_MAXSTEP, maxstep);
}


BEGIN_MESSAGE_MAP(CParameter, CDialog)
	ON_BN_CLICKED(IDC_BUTTON_SET, OnBnClickedButtonSet)
END_MESSAGE_MAP()


// CParameter 消息处理程序

void CParameter::OnBnClickedButtonSet()
{
	// TODO: 在此添加控件通知处理程序代码
	int tmp_her = her;
	int tmp_sleep = sleep;
	int tmp_maxstep = maxstep;
	UpdateData();
	CString str;
	if(sleep < 200 || sleep > 2000){
		str += "演示延迟时间必须在200~2000ms之间。";
		SetDlgItemInt(IDC_SLEEP, tmp_sleep);
	}
	if(her < 0 || her > 100){
		if(str != "")
			str += "\r\n";
		str += "启发函数h(x)的系数必须在0~100之间。";
		SetDlgItemInt(IDC_HER, tmp_her);
	}
	if(maxstep < 5 || maxstep > 50){
		if(str != "")
			str += "\r\n";
		str += "深度优先的界限必须在5~50之间。";
		SetDlgItemInt(IDC_MAXSTEP, tmp_maxstep);
	}
	if(str != ""){
		UpdateData();
		MessageBox(str, "错误");
	}else
		EndDialog(1000);
}

void CParameter::GetParameter(int & m_her, int & m_sleep, int & m_maxstep)
{
	m_her = her;
	m_sleep = sleep;
	m_maxstep = maxstep;
}

⌨️ 快捷键说明

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