C++ Hexadecimal Calculator Multiplication
<p>I'm having issues where my multiplication method is only handling one row, it's currently not advancing to the next row. The add function is working properly, and I'm able to update the current hex number, but for some reason I can only get one line of multiplication to work.</p>

<pre><code>Example input:
111# * 333# = 333
123# * 123# = 369
</code></pre>

<p>Here is the code in question:</p>

<pre><code>    LList* Calculator::multiply(LList&amp; left, LList&amp; right) {
    int product, carry = 0, lval = 0, rval = 0, zeros = 0;
    bool calculating = true;
    listnode *leftNode;
    vector &lt;LList*&gt; addList;
    listnode *rightNode;
    LList* newHex;
    while(calculating) {

        leftNode = left.next();
        if(leftNode == NULL) {
            break;
        }
        else {
            lval = leftNode-&gt;data;
        }


        //leftNode = left.next();
        right.reset();

        if(leftNode == NULL) {
            calculating = false;
            if(carry != 0) {
                //newHex-&gt;insertTail(carry);
            }
            lval = 0;
            break;
        }

        LList* curList = new LList;
        addList.push_back(curList);

        while(rightNode != NULL) {

            // Add however zeros we need for
            // each entry based on the zero counter
            for(int i = 0; i &lt; zeros; i++) {
                curList-&gt;insertTail(0);
            }

            rightNode = right.next();


            if(rightNode == NULL) {

            } 
            else {
            rval = rightNode-&gt;data;

            product = lval * rval + carry;
            carry = 0;
            if(product &gt;= 16) {
                carry = (product / 16);
                product = (product % 16);
            }
            curList-&gt;insertTail(product);
            }
        }
        zeros++;


    }

    Calculator calc;
    LList* temp;
    // Add up everything in the addList
    for(int i = 0; i &lt; addList.size() - 1; i++) {
        if(temp == NULL)
            temp = calc.add(*addList[i], *addList[i+1]);
        else
            temp = calc.add(*addList[i+1], *temp);
    }

    newHex = temp;

    // Delete it
    for(int i = 0; i &lt; addList.size(); i++) {

    }

    return newHex;
};
</code></pre>

<p>Here is the next method:</p>

<pre><code>listnode* LList::next() {
    listnode* temp = view;
    if(temp != NULL)
        view = view-&gt;next;

    if(view == NULL) {
    }
    return temp;
};
</code></pre>

<p>FUll PROGRAM:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;stdlib.h&gt;
#include &lt;string&gt;
using namespace std;
#undef NULL
const int NULL = 0;
const char SENTINEL = '#';
typedef int element;

class listnode {
    public:
        element data;
        listnode * next;
};

class LList {
    private:
        listnode * head;
        listnode * tail;
        listnode * view;

    public:
        LList();
        ~LList();
        void read();
        listnode* next();
        void reset();
        void print();
        void insertTail(element val);
        void clean();

        element deleteHead();
};

class Calculator {
    public:
        Calculator();
        inline LList* add(LList&amp; left, LList&amp; right);
        inline LList* multiply(LList&amp; left, LList&amp; right);
};

Calculator::Calculator() {

};

LList* Calculator::add(LList&amp; left, LList&amp; right) {
    int sum, carry = 0, lval = 0, rval = 0;
    bool calculating = true;
    listnode *leftNode;
    listnode *rightNode;
    LList* newHex = new LList;
    while(calculating) {
        leftNode = left.next();
        rightNode = right.next();

        if(leftNode == NULL) {
            lval = 0;
        }
        else
            lval = leftNode-&gt;data;

        if(rightNode == NULL) {
            rval = 0;
        }
        else
            rval = rightNode-&gt;data;


        if(leftNode == NULL &amp;&amp; rightNode == NULL) {
            calculating = false;
            if(carry != 0) {
                newHex-&gt;insertTail(carry);
            }
            break;
        }

        sum = lval + rval + carry;
        carry = 0;
        if(sum &gt;= 16) {
            carry = 1;
            sum -= 16;
        }

        newHex-&gt;insertTail(sum);

    }

    return newHex;
};


LList* Calculator::multiply(LList&amp; left, LList&amp; right) {
    int product, carry = 0, lval = 0, rval = 0, zeros = 0;
    bool calculating = true;
    listnode *leftNode;
    vector &lt;LList*&gt; addList;
    listnode *rightNode;
    LList* newHex;
    while(calculating) {

        leftNode = left.next();
        if(leftNode == NULL) {
            break;
        }
        else {
            lval = leftNode-&gt;data;
        }


        //leftNode = left.next();
        right.reset();

        if(leftNode == NULL) {
            calculating = false;
            if(carry != 0) {
                //newHex-&gt;insertTail(carry);
            }
            lval = 0;
            break;
        }

        LList* curList = new LList;
        addList.push_back(curList);

        while(rightNode != NULL) {

            // Add however zeros we need for
            // each entry based on the zero counter
            for(int i = 0; i &lt; zeros; i++) {
                curList-&gt;insertTail(0);
            }

            rightNode = right.next();


            if(rightNode == NULL) {

            } 
            else {
            rval = rightNode-&gt;data;

            product = lval * rval + carry;
            carry = 0;
            if(product &gt;= 16) {
                carry = (product / 16);
                product = (product % 16);
            }
            curList-&gt;insertTail(product);
            }
        }
        zeros++;


    }



    Calculator calc;
    LList* temp;
    // Add up everything in the addList
    for(int i = 0; i &lt; addList.size() - 1; i++) {
        if(temp == NULL)
            temp = calc.add(*addList[i], *addList[i+1]);
        else
            temp = calc.add(*addList[i+1], *temp);
    }

    newHex = temp;

    // Delete it
    for(int i = 0; i &lt; addList.size(); i++) {

    }

    return newHex;
};

listnode* LList::next() {
    listnode* temp = view;
    if(temp != NULL)
        view = view-&gt;next;

    if(view == NULL) {
    }
    return temp;
};

void LList::reset() {
    view = head;
}


LList::LList(){
    /*
    next:
    This is used to set the linked
    list to NULL.
    */
    head = NULL;
    view = NULL;
};


void LList::print() {
    listnode * temp;
    int i = 0;
    string printValues;
    temp = head;
    while(temp != NULL) {
        int var = temp -&gt; data;
        char character = ' ';
        if(i % 3 == 0 &amp;&amp; i != 0)
            printValues += ',';
        i++;    
        if(var &gt; 9 &amp;&amp; var &lt; 16) {
            character = static_cast &lt;char&gt;(var + 65 - 10);
        };
        if (var &lt;= 9 &amp;&amp; var &gt;= 0) {
            character = static_cast &lt;char&gt;(var + 48);
        };
        if (var &gt; 96 &amp;&amp; var &lt; 103) {
            character = static_cast &lt;char&gt;(var + 97 + 10);
        };

        printValues += character;
        temp = temp -&gt; next;

    }
    string tempValues;
    for(int i = printValues.length() - 1; i &gt;= 0; i--)
        tempValues += printValues[i];
    cout &lt;&lt; tempValues;
    cout &lt;&lt; endl;
};

 void LList::read() {
    string userval;
    int i;
    bool parsing = true;
    char curval;
    vector &lt;int&gt; values;
    clean();
    while(parsing) {
        cin &gt;&gt; userval;
        for(unsigned int i = 0; i &lt; userval.length(); i++) {
            curval = userval[i];    
            if(curval &gt;= 48 &amp;&amp; curval &lt;= 57)
                values.push_back(static_cast &lt;int&gt;(curval - 
            48));

            if(curval &gt;= 65 &amp;&amp; curval &lt;= 70)
                values.push_back(static_cast &lt;int&gt;(curval - 
            65 + 10));

            if(curval &gt;= 97 &amp;&amp; curval &lt;= 102)
                values.push_back(static_cast &lt;int&gt;(curval - 
            97 + 10)); 

            if(curval == ' ')
                break;

            if(curval == SENTINEL) {
                parsing = false;
                break;
            }   
        }
    }
    for(int i = values.size() -1; i &gt;= 0; i--) {
        insertTail(values[i]);
    }
}; 

void LList::insertTail(element val) {
    listnode * temp;
    temp = new listnode;
    temp -&gt; data = val;
    temp -&gt; next = NULL;

    if(head == NULL) {
        head = temp;
        view = head;
    }
    else
        tail -&gt; next = temp;
    tail = temp;
};

void LList::clean() {
    while(head != NULL)
        deleteHead();
};

void validCommands() {
    cout &lt;&lt; "Valid commands are:" &lt;&lt; endl;
    cout &lt;&lt; "  e enter  enter the current ";
    cout &lt;&lt; "hexadecimal ";
    cout &lt;&lt; "number from the keyboard" &lt;&lt; endl;
    cout &lt;&lt; "  a add        add a new hexadecimal ";
    cout &lt;&lt; "number to the current hex. number" &lt;&lt; endl;
    cout &lt;&lt; "  m multiply   ";
    cout &lt;&lt; "multiply a new hexadecimal number ";
    cout &lt;&lt; "by the current hex. number" &lt;&lt; endl;
    cout &lt;&lt; "  h help   show this help menu" &lt;&lt; endl;
    cout &lt;&lt; "  q quit   quit the program" &lt;&lt; endl &lt;&lt; endl;
};

element LList::deleteHead() {
    listnode * temp;
    temp = head;
    head = head -&gt; next;
    delete temp;
    return temp -&gt; data;
};

LList::~LList(){
    delete head;
};

int main() {
    LList L, add,multiply;
    Calculator calc;
    L.insertTail(0);
    char option;
    bool run;
    cout &lt;&lt; "Hexadecimal Calculator, Ver 1.0.0 \n";



    do {
        /*
    This do while is used to continuosly run the 
    program until the user decides to end.
    */
    cout &lt;&lt; "Current Hexadecimal number is: ";
    L.print();
    cout &lt;&lt; endl;

    cout &lt;&lt; "Command (h for help): ";
    cin &gt;&gt; option;

    cout &lt;&lt; endl &lt;&lt; endl;
        switch(option) {
            case 'e' : 
                cout &lt;&lt; "Enter a hexadecimal number ";
                cout &lt;&lt; "followed by #: ";
                L.read();
                cout &lt;&lt; endl &lt;&lt; "Entering completed.";
                cout &lt;&lt; endl &lt;&lt; endl;
            break;
            case 'a' :  
                cout &lt;&lt; "Adding a new hexadecimal number ";
                cout &lt;&lt; "to the current hex. number" &lt;&lt; endl;
                cout &lt;&lt; endl;
                cout &lt;&lt; "Enter a hexadecimal ";
                cout &lt;&lt; "number, follow by #: ";
                add.read();
                cout &lt;&lt; endl &lt;&lt; "Addition completed.";
                cout &lt;&lt; endl;
                L = *calc.add(L, add);
                cout &lt;&lt; endl;
                break;
            case 'm' : 
                cout &lt;&lt; "Multiplying a new hexadecimal ";
                cout &lt;&lt; "number ";
                cout &lt;&lt; "to the current hex. number" &lt;&lt; endl;
                cout &lt;&lt; endl;
                cout &lt;&lt; "Enter a hexadecimal ";
                cout &lt;&lt; "number, follow by #: ";
                multiply.read();
                cout &lt;&lt; endl &lt;&lt; "Multiplication completed.";
                cout &lt;&lt; endl;
                L = *calc.multiply(L, multiply);
                cout &lt;&lt; endl;
                break;
            case 'h' : validCommands();
            break;
            case 'q' : run = false;
            break;
        };
    } while (run);
        exit(0);

}
</code></pre>