Sorry if this is a bad question for posting.. but I'm confused as to where I'm going wrong. The assignment is to read in different shapes from a text file and put them in a linked list.
I put here the two classes in the program that I think are relevant. The issue I'm having is that the program seems to be reading each shape in twice, so for example when I print the list I am somehow adding two of each shape rather than one. I have figured out that I can add an extra line of code somewhere, for example in the getShape() method in the Input class I can add another call of readInput(); and it will only add one of each shape to the linked list. Similarly in the ShapeDriver constructor while loop I can say i.getShape(); and it will also add each shape only once. I feel like these aren't really solutions to my error, though, just coverups.
I'm just not seeing why it seems to be reading and adding each shape twice.
In case it helps the input text file looks something like this
As far as readInput() encountering errors, it's been stated in the assignment requirements that that won't happen. I.E. there will always be the correct number of sides for each shape. In the event that a side has length zero or less than zero, that error is handled in the individual shape's class.
getShape() just calls readInput(), and readInput() simply stores the new shape it creates in the protected _shape object. That _shape object is then returned when getShape() is called.