I'm getting something weird

Pages: 12
Thanks, but that haven't fixed anything!

I'm sorry but none of you are helping me get this:
c_in a b c_out s
-----------+---------
0 0 0 | 0 0
0 0 1 | 0 1
0 1 0 | 0 1
0 1 1 | 1 0
1 0 0 | 0 1
1 0 1 | 1 0
1 1 0 | 1 0
1 1 1 | 1 1
Thanks, but that haven't fixed anything!
I'm sorry but none of you are helping me get this:


I pointed out to you a major problem with your code. It occurs in more than just the place that I reproduced in the code tags, and I indicated it occurred more than one time in the previous post. Have you corrected that problem everywhere it occurs?

For instance, given the problem described in my earlier post how should:
1
2
3
4
                FullAdder adder;
                adder.FullAdder::FullAdder(inputA, inputB, inputC);
                cout << "   " << inputC << "  " << inputA << "  " << inputB << " |     ";
                cout << adder.GetOutputC() << "  " << adder.GetOutputS() << endl;

be rewritten?
1
2
3
4
FullAdder adder;
cout << "   " << inputC << "  " << inputA << "  " << inputB << " |     "; 
cout << adder.GetOutputC() << "  " << adder.GetOutputS() << endl;
}


But this doesn't fixed anything!
My main problem is that I am getting this:
c_in a b c_out s
-----------+---------
0 0 0 | -858993460 -858993460
0 0 1 | -858993460 -858993460
0 1 0 | -858993460 -858993460
0 1 1 | -858993460 -858993460
1 0 0 | -858993460 -858993460
1 0 1 | -858993460 -858993460
1 1 0 | -858993460 -858993460
1 1 1 | -858993460 -858993460
How am I not doing it?

1
2
mOutputC = mOr.GetOutput();
mOutputS = mXor2.GetOutput();


...


Yes, those lines are in void FullAdder::Eval(). How do you call FullAdder::Eval() from void FullAdderTest::Run() either directly or indirectly?
Well here's my function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void FullAdderTest::Run()
{
    cout << "Testing the FullAdder class" << endl;
    cout << "c_in  a  b   c_out  s" << endl;
    cout << "-----------+---------" << endl;
    for (int inputC = 0; inputC <= 1; inputC++)
    {
        for (int inputA = 0; inputA <= 1; inputA++)
        {
            for (int inputB = 0; inputB <= 1; inputB++)
            {
                FullAdder adder;
                cout << "   " << inputC << "  " << inputA << "  " << inputB << " |     ";
                cout << adder.GetOutputC() << "  " << adder.GetOutputS() << endl;
            }
        }
    }
}


And I did this:
1
2
3
4
int FullAdder::GetOutputS()
{
    return mOutputS = mXor2.GetOutput();
}


1
2
3
4
int FullAdder::GetOutputC()
{
    return mOutputC = mOr.GetOutput();
}


And now I'm getting this:
c_in a b c_out s
-----------+---------
0 0 0 | 0 0
0 0 1 | 0 0
0 1 0 | 0 0
0 1 1 | 0 0
1 0 0 | 0 0
1 0 1 | 0 0
1 1 0 | 0 0
1 1 1 | 0 0
Last edited on
I know it probably coming from this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void FullAdder::Eval()
{
    mXor1.SetInputA(mInputA);
    mXor1.SetInputB(mInputB);
    mXor2.SetInputA(mXor1.GetOutput());
    mXor2.SetInputB(mInputC);
    mAnd1.SetInputA(mXor1.GetOutput());
    mAnd1.SetInputB(mInputC);
    mAnd2.SetInputA(mInputA);
    mAnd2.SetInputB(mInputB);
    mOr.SetInputA(mAnd1.GetOutput());
    mOr.SetInputB(mAnd2.GetOutput());
    mOutputC = mOr.GetOutput();
    mOutputS = mXor2.GetOutput();
}


Here's what I'm supposed to:
Call mXor1.SetInputA() passing mInputA as the param.
Call mXor1.SetInputB() passing mInputB as the param.
Call mXor2.SetInputA() passing the output from mXor1 as the param.
Call mXor2.SetInputB() passing mInputC as the param.
Call mAnd1.SetInputA() passing the output from mXor1 as the param.
Call mAnd1.SetInputB() passing mInputC as the param.
Call mAnd2.SetInputA() passing mInputA as the param.
Call mAnd2.SetInputB() passing mInputB as the param.
Call mOr.SetInputA() passing the output from mAnd1 as the param.
Call mOr.SetInputB() passing the output from mAnd2 as the param.
Set mOutputC to the output from mOr.
Set mOutputS to the output from mXor2.
Edit:

I missed that you were saying that you revised your two get functions so instead of just returning mOutputC and mOutputS you are setting them from GetOutput methods in two different classes. But both methods just return the private mOutput variables. So the question changes to when are those variables set and are they set correctly.

Revised original:
Start from Lab11.cpp main(). Track which functions are actually called (by using paper and pencil or possibly a debugger). Not all your functions are actually used.

By doing that tracking you can answer my revised question. Revised question: Starting from Lab11.cpp main(), where do you call FullAdder::Eval()? FullAdder::Eval() is the only place you currently set mOutputC and mOutputS. Yes, you have code that calls FullAdder::Eval() but that code never gets called by your Lab11.cpp main() or the functions that it calls.
Last edited on
1
2
3
4
FullAdder adder;
cout << "   " << inputC << "  " << inputA << "  " << inputB << " |     "; 
cout << adder.GetOutputC() << "  " << adder.GetOutputS() << endl;
}


But this doesn't fixed anything!


That's true. But mostly because you just removed the code instead of replacing it with what needs to be there. That would fix something, but it still wouldn't solve your problem. (In other words, there are multiple problems with your code and fixing just one of them isn't going to give you the output you want.)
Can you at least show me the problems?
Have you considered calling your eval() functions from your constructors? In some of your classes you are. If that is not appropriate (which it might not be), then consider setting all the class variables to appropriate values during the constructors. So as soon as an object is created, its get... methods will return appropriate results.
Last edited on
I've tried and it's not working.

As I said, I'm supposed to:
Call mXor1.SetInputA() passing mInputA as the param.
Call mXor1.SetInputB() passing mInputB as the param.
Call mXor2.SetInputA() passing the output from mXor1 as the param.
Call mXor2.SetInputB() passing mInputC as the param.
Call mAnd1.SetInputA() passing the output from mXor1 as the param.
Call mAnd1.SetInputB() passing mInputC as the param.
Call mAnd2.SetInputA() passing mInputA as the param.
Call mAnd2.SetInputB() passing mInputB as the param.
Call mOr.SetInputA() passing the output from mAnd1 as the param.
Call mOr.SetInputB() passing the output from mAnd2 as the param.
Set mOutputC to the output from mOr.
Set mOutputS to the output from mXor2.

And right now I have:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
    mXor1.SetInputA(mInputA);
    mXor1.SetInputB(mInputB);
    mXor2.SetInputA(mXor1.GetOutput());
    mXor2.SetInputB(mInputC);
    mAnd1.SetInputA(mXor1.GetOutput());
    mAnd1.SetInputB(mInputC);
    mAnd2.SetInputA(mInputA);
    mAnd2.SetInputB(mInputB);
    mOr.SetInputA(mAnd1.GetOutput());
    mOr.SetInputB(mAnd2.GetOutput());
    mOutputC = mOr.GetOutput();
    mOutputS = mXor2.GetOutput();
}
Last edited on
Seriously I need it fixed by tomorrow morning.
You've been informed of two problems which, when both are corrected, will lead to the desired output. Namely that Eval on FullAdder objects is only called in circumstances which don't occur in your program, and that you need to invoke the proper constructor for your FullAdder object.

So... maybe pay attention to what you've already been told.
Last edited on
When have you told me? You haven't show me anything! I've been asking for help, but so far all I'm getting is vague comments! Sorry I don't get computing lingo. Just please show me what I'm doing wrong.

I'm sorry, but whenever I have asked this site for something, I feel like I being treated like an idiot. And the fact that it takes an hour for someone to respond, it's just...
Last edited on
You know what, fuck it.
To be honest with you, people like me will not respond and help you because of your attitude.

So how do I fixed it? I need it fixed by Sunday.

We're volunteers here, we don't come here to do people's homework for them. If you're incapable of doing your own homework then you deserve to fail the paper.

but so far all I'm getting is vague comments! Sorry I don't get computing lingo. Just please show me what I'm doing wrong.

Our role here is to guide you to find the solution yourself as much as possible. We don't code solutions for people.

I'm sorry, but whenever I have asked this site for something, I feel like I being treated like an idiot. And the fact that it takes an hour for someone to respond, it's just...

This is entirely your own fault.

You posted a problem, then demanded a solution. You didn't even take the time to provide us with the project files in an easy manner to download and compile so we can run it and replicate your results. Nope, you just posted a bunch of code that we'd have to copy and paste in to a new project and configure (wasting our time).

Then, you complain about the time it takes to get a response. Are you paying us? no.. is anyone paying us? no. We volunteer our time here to help other people solve problems they have with their projects. People who legitimately try and show us this. People who show up and demand solutions usually just get left in the dark.

Last edited on
Topic archived. No new replies allowed.
Pages: 12