An abstract class Stack - without data representation - with a non-abstract ToggleTop method. | Lecture 8 - slide 7 : 37 Program 1 |
using System; public abstract class Stack{ abstract public void Push(Object el); abstract public void Pop(); abstract public Object Top{ get;} abstract public bool Full{ get;} abstract public bool Empty{ get;} abstract public int Size{ get;} public void ToggleTop(){ if (Size >= 2){ Object topEl1 = Top; Pop(); Object topEl2 = Top; Pop(); Push(topEl1); Push(topEl2); } } public override String ToString(){ return String.Format("Stack[{0}]", Size ); } } |