I can’t get the top element from the stack (consisting of an element of two child classes)
implementation of the wall class and its child classes, as well as the stack itself.
here I add classes to the stack and using the isBuildingCorrectly function I check whether I can insert the next object, but when I access the fields of the object that is on the stack from the stack, an error is generated