数独对象开发Class_sudo_unit

以下内容已经经过初步验证,虽不是很如意,不过还是决定先共享出来。。。

 

< meta http - equiv = " Content-Type "  content = " text/html; charset=gb2312 " >
< %
' '数独对象开发
'
++++++++++++++++++++++++++++++++++++++++++
'
灵异生存 Linyee
'
2007-8-31 至 2007-9
'
Class_sudo_unit:
'
++++++++++++++++++++++++++++++++++++++++++

' ++++++++++++++++++++++++++++++++++++++++++
'
Class_sudo_unit:    数独单元对象类
'
------------------------------------------
'
'
SuBase:        基本单元格数,数基则为1-SuBase^2,由引用类提供值
'
Value:            数值:0则候选;1-9为确认值,-1错误
'
WillValList:    候选数组合:空则错误,长度1确认,其它为候选组合;建议用' '分隔的组合
'
-----其它属性
'
Line:            行
'
Row:            列
'
Area:            区
'
++++++++++++++++++++++++++++++++++++++++++
Dim  sdunit
set  sdunit     = new  Class_sudo_unit
' '============================

Class Class_sudo_unit
    
private     x_pri_subase,x_pri_Value,x_pri_willValues
    
' '最高可用值
     private  x_pri_suMax,x_pri_IsUpdate    
    
private  x_pri_line,x_pri_row,x_pri_area
    
private     x_pri_numofarea     ' '
     private  x_pri_cls_msg,x_pri_cls_Err,x_pri_for_i
    
' '区内第几格
     private  x_pri_tmp_i
    
    
' '---------------------------
     ' '''''''''''取值
     public   property   get  Value()
        Value
= x_pri_Value
    
End property
    
public   property   get  Line()
        Line
= x_pri_line
    
End property
    
public   property   get  Row()
        Row
= x_pri_row
    
End property
    
public   property   get  Area()
        Area
= x_pri_area
    
End property
    
public   property   get  WillValList()
        WillValList
= x_pri_willValues
    
End property
    
public   property   get  NumOfArea()
        NumOfArea
= x_pri_numofarea
    
End property
    
    
public   property   get  SuBase()
        SuBase
= x_pri_subase
    
End property
    
public   property   get  suMax()
        suMax
= x_pri_suMax
    
End property
    
    
public   property   get  IsErr()
        IsErr
= x_pri_cls_Err
    
End property
    
public   property   get  IsUpdate()
        IsUpdate
= x_pri_IsUpdate
        x_pri_IsUpdate
= False
    
End property
    
    
    
' '''''''''设置
    
    
public   property   let  SuBase(byval v_newValue)
        x_pri_cls_Err
= False
        
if  x_pri_area > 0   then
            x_pri_cls_msg
= x_pri_cls_msg & " <li>现在不可更改基数值</li> "
            x_pri_cls_Err
= True
        
elseif  v_newValue < 2   then
            x_pri_cls_msg
= x_pri_cls_msg & " <li>设置基数值应不小2</li> "
            x_pri_cls_Err
= True
        
else
            x_pri_subase    
= Int (v_newValue)
            x_pri_suMax        
= x_pri_subase ^ 2
            x_pri_willValues
= ""
            
for  x_pri_for_i = 1   to  x_pri_suMax
                x_pri_willValues
= x_pri_willValues & "   " & x_pri_for_i
            
next
            x_pri_willValues
= x_pri_willValues & "   "
        
end   if
    
End property
    
    
public   property   let  Line(byval v_newValue)
        x_pri_cls_Err
= False
        
if  x_pri_area > 0   then
            x_pri_cls_msg
= x_pri_cls_msg & " <li>现在不可更改行列区参数值</li> "
            x_pri_cls_Err
= True
        
elseif  v_newValue < 1   then
            x_pri_cls_msg
= x_pri_cls_msg & " <li>行列区参数值不于1</li> "
            x_pri_cls_Err
= True
        
else
            x_pri_line    
= Int (v_newValue)
            
if  x_pri_row > 0   then
                x_pri_area    
= ((x_pri_line - 1 ) x_pri_subase) * x_pri_subase + (x_pri_row - 1 ) x_pri_subase + 1
                x_pri_numofarea
= ((x_pri_line - 1 ) mod  x_pri_subase) * x_pri_subase + (x_pri_row - 1 ) mod  x_pri_subase + 1
            
end   if
        
end   if
    
End property
    
    
public   property   let  Row(byval v_newValue)
        x_pri_cls_Err
= False
        
if  x_pri_area > 0   then
            x_pri_cls_msg
= x_pri_cls_msg & " <li>现在不可更改行列区参数值</li> "
            x_pri_cls_Err
= True
        
elseif  v_newValue < 1   then
            x_pri_cls_msg
= x_pri_cls_msg & " <li>行列区参数值不于1</li> "
            x_pri_cls_Err
= True
        
else
            x_pri_row    
= Int (v_newValue)
            
if  x_pri_line > 0   then
                x_pri_area    
= ((x_pri_line - 1 ) x_pri_subase) * x_pri_subase + (x_pri_row - 1 ) x_pri_subase + 1
                x_pri_numofarea
= ((x_pri_line - 1 ) mod  x_pri_subase) * x_pri_subase + (x_pri_row - 1 ) mod  x_pri_subase + 1
            
end   if
        
end   if
    
End property
    
    
public   property   let  Value(byval v_newValue)
        x_pri_cls_Err
= False
        
if  x_pri_subase < 2   then
            x_pri_cls_msg
= x_pri_cls_msg & " <li>设置值前,请先正确设置基数。</li> "
            x_pri_cls_Err    
= True
        
elseif  x_pri_line < 1   then
            x_pri_cls_msg
= x_pri_cls_msg & " <li>设置值前,请先正确设置行列参数。</li> "
            x_pri_cls_Err    
= True
        
elseif  x_pri_row < 1   then
            x_pri_cls_msg
= x_pri_cls_msg & " <li>设置值前,请先正确设置行列参数。</li> "
            x_pri_cls_Err    
= True
        
elseif  x_pri_area < 1   then
            x_pri_cls_msg
= x_pri_cls_msg & " <li>设置值前,请先正确设置行列参数。</li> "
            x_pri_cls_Err    
= True
        
elseif  v_newValue < 0   then
            x_pri_cls_msg
= x_pri_cls_msg & " <li>值必大于0</li> "
            x_pri_cls_Err    
= True
        
elseif  v_newValue > x_pri_suMax  then
            x_pri_cls_msg
= x_pri_cls_msg & " <li>值必小于等于 " & (x_pri_suMax) & " </li> "
            x_pri_cls_Err    
= True
        
else
            x_pri_Value        
= Int (v_newValue)
            
if  v_newValue > 0   then  x_pri_willValues = v_newValue:x_pri_IsUpdate = True
        
end   if
    
End property
    
' '---------------------------
     ' '错误信息提取
     Public   Function  ErrMsg()
        ErrMsg
= ""
        
if  x_pri_cls_Err = True   then  ErrMsg = x_pri_cls_msg
        
        x_pri_cls_msg
= ""
        x_pri_cls_Err
= False
    
End Function
    
    
' '初始化类事件
     Private   Sub  Class_Initialize()
        x_pri_cls_msg
= ""
        x_pri_cls_Err
= false
        x_pri_for_i
= 0
        
        x_pri_IsUpdate
= False
        
        x_pri_subase
= 0
        x_pri_Value
= 0
        x_pri_willValues
= ""
        
        x_pri_line
= 0
        x_pri_row
= 0
        x_pri_area
= 0
    
End Sub
    
    
' '终止类事件
     Private   Sub  class_terminate()
    
End Sub
    
' '---------------------------
    
    
' '候选数删减
     Public   Function  WillNum_sub(byVal subNumber)
        WillNum_sub
= True
        
        
Dim  tmp_will
        x_pri_willValues
= Replace (x_pri_willValues, "   " & subNumber & "   " , "  0  " )
        tmp_will
= Trim ( Replace (x_pri_willValues, "  0 " , "" ))
        
' '唯一值时
         if   IsNumeric (tmp_will)  then
            x_pri_Value        
= Int (tmp_will)
            x_pri_IsUpdate    
= True      ' 对于
         end   if
        
' '出错时
         if  tmp_will = ""   then
            WillNum_sub
= False
            x_pri_cls_msg
= x_pri_cls_msg & " <li>无解或系统错误!</li> "
            x_pri_cls_Err
= True
            x_pri_Value
=- 1
        
end   if
    
End Function

End  Class
%
>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

灵易联盟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值