Dejhnb.m

qsasa
Last edited on
sasa
Last edited on
What exactly is going wrong? What are the possible solutions, that you are aware of? I think by the forum's rules, you are required to give a bit more information on what you need, seeing how this appears to be homework.
Indeed, especially considering most people don't really want to wade through two posts worth of code to find errors.
ijkl
Last edited on

Check your ShowValue values in the following they are both forced to false. Apply Filter was not even accessed.
You may need to rethink that or finish the logic.

TheFilter::ShowValue_Valid()
TheData::ShowValue_Valid()

I commented the two condition checks and the ApplyFilter ran fine


The input data values
---------------------
[ 1 2 3 4 5 ]

The data output values
----------------------
[ 5 8 11 14 ]

The filter values
-----------------
[ 1 2 ]

To output I just changed your for loops:

1
2
3
4
 for (unsigned long CountData = 0; CountData < OriginalData.Length; CountData++)
{
       cout << " " << OriginalData.Values[CountData];
}


1
2
3
4
for (unsigned long CountData = 0; CountData < FilteredData.Length; CountData++)
 {
         cout << " " << FilteredData.Values[CountData];
 }


1
2
3
4
    for (unsigned long CountData = 0; CountData < Filter.Length; CountData++)
    {
        cout << " " << Filter.Values[CountData];
    }



Last edited on
khj
Last edited on

There is a bug change OriginalData to FilteredData

96
97
98
99
        case '1':
            OriginalData.EnterData(OriginalData);
            FilteredData.SetValue(false, FilteredData);
            break;


These are the loops I changed

200
201
202
203
for (unsigned long CountData = 0; CountData < OriginalData.Length; CountData++)
{
       cout << " " << OriginalData.Values[CountData];
}


213
214
215
216
for (unsigned long CountData = 0; CountData < FilteredData.Length; CountData++)
 {
         cout << " " << FilteredData.Values[CountData];
 }



You need to return the private variable values, they were return false values.

235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
double* TheData::ShowValue_Values()
{
    return Values;
}

unsigned long TheData::ShowValue_Length()
{
    return Length;
}

bool TheData::ShowValue_Valid()
{
    return Valid;
}



This is in the 2nd post

88
89
90
91
for (unsigned long CountData = 0; CountData < Filter.Length; CountData++)
    {
        cout << " " << Filter.Values[CountData];
    }


Same here, these need to return the private variable values.

114
115
116
117
118
119
120
121
122
123
124
125
126
127
double* TheFilter::ShowValue_Values()
{
    return Values;
}

unsigned long TheFilter::ShowValue_Length()
{
    return Length;
}

bool TheFilter::ShowValue_Valid()
{
    return Valid;
}



The criteria in cases 3 & 4 now work correctly.

Good luck :)



Don't worry sometimes you have to take a step back.
Add breakpoints and output variables to help you troubleshoot problem code.

Learn using the debugger. If you use an IDE, you can add checkpoints and watchpoints to help.



Topic archived. No new replies allowed.