不匹配运算符||在我的bool功能

时间:2015-10-28 07:52:08

标签: c++

bool ComputerType::validData()
// PURPOSE: validates data 
// INPUT: idNumber, processor, RAMSize, DiskSize, ComputerType, cost,    labLocation
    // PRE: Reads all data and determines if they are valid or invalid 
    // OUTPUT:m_idNumber, m_processor, m_RAMSize, m_DiskSize, m_ComputerType, m_cost, m_labLocation
    // POST: data is valid or invalid 
    // NOTE:None
    {
      if(m_idNumber >= MIN_ID && m_idNumber <= MAX_ID && ((m_RAMSize+m_ramSuffix) == "4GB" || (m_RAMSize+m_ramSuffix) == "8GB"
        || (m_RAMSize+m_ramSuffix) == "16GB" || (m_RAMSize+m_ramSuffix) == "32GB" && ((m_DiskSize+m_diskSuffix) == "500GB"
        || (m_DiskSize+m_diskSuffix) == "1TB" || (m_DiskSize+m_diskSuffix) == "2TB") && (m_computerType == "Laptop"
        || m_computerType == "Desktop") && (m_cost >= MIN_COST && m_cost <= MAX_COST) && (m_labLocation == "SE145"
        || m_labLocation = "SE135" || m_labLocation == "SE136")))
        {
          return true;
        }
        else
        {
          return false; 
        } 
    }

这是我的代码

1 个答案:

答案 0 :(得分:6)

preRenderView

仔细看看那一点。

但你真正的问题应该是“如何调试这样的东西?”一种方法是将大量复杂的m_labLocation = "SE135" 语句分解为许多较小的语句。这至少会减少您需要查看的代码量。

例如:

if

基本上,你只是将你得到错误的行分成更小和更小的行,直到你只剩下一小段代码。