File tree Expand file tree Collapse file tree 2 files changed +17
-22
lines changed Expand file tree Collapse file tree 2 files changed +17
-22
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,15 @@ bool is_valid(Array<string> & infix) {
196196 return true ;
197197}
198198
199+ // COMMENT You should move the priority to the nodes. The reasoning is because
200+ // you violate the DIP. If you want to add new operators to your calculator, then
201+ // you must update this method to understands its priority. Also, the concrete
202+ // builder should be handling the priority.
203+
204+ // SOLUTION:
205+ //
206+ // set _priority in Binary_Op_Node and use it in child node classes.
207+
199208/* *
200209* Returns operator priority to use for order-of-operations
201210* @param: std::string some operator in string format
@@ -324,6 +333,14 @@ int main(int argc, char * argv[]) {
324333
325334 // enqueue valid expression, exception if invalid
326335 if (is_valid (infix)) {
336+
337+ // COMMENT: Do not go from infix to postfix then to tree. Instead,
338+ // go directly from infix to tree. The extra step is not necessary.
339+
340+ // SOLUTION:
341+ //
342+ // It's to build function get expression tree from infix queue instead of postfix
343+
327344 // get postfix
328345 Queue<string> postfix = infix_to_postfix (infix);
329346
Original file line number Diff line number Diff line change 1- // //////////////////////////////////////////////////////////////////////////////
2- //
3- // Author: Ibrahim Sardar
4- // Class: CSCI 363
5- // Filename: div_Node_P.h
6- // Date: 11/20/2017
7- // Description: Headers for div_Node_P class.
8- //
9- // //////////////////////////////////////////////////////////////////////////////
10- //
11- // Honor Pledge:
12- //
13- // I pledge that I have neither given nor received any help on this assignment.
14- //
15- // ibsardar
16- //
17- // //////////////////////////////////////////////////////////////////////////////
18- //
19- // Copyright (c) 2017 Copyright Holder All seconds Reserved.
20- //
21- // //////////////////////////////////////////////////////////////////////////////
22-
231#ifndef _DIVIDE_NODE_H_
242#define _DIVIDE_NODE_H_
253
You can’t perform that action at this time.
0 commit comments