Implement a token ring with RingManager and RingElement classes.
Implement a ring of elements where only one element holds the "token" at any time. The first created element starts with the token. Calling release() passes the token to the next element in the ring. The ring is circular: releasing from the last element returns the token to the first.
Example asserts that had to pass: RingManager ringtest; RingElement piece1 = ringtest.create(); assert(piece1.hasToken()); // first element gets token RingElement piece2 = ringtest.create(); assert(piece1.hasToken()); // still with piece1 piece2.release(); assert(!piece1.hasToken()); assert(piece2.hasToken()); // token moved to piece2 piece2.release(); // token goes back to piece1 (circular)
C++ template given in the interview: #include <vector> #include <memory> class RingManager; class RingElement { private: public: bool hasToken(...) const; void release(...); }; class RingManager { private: public: RingManager(){} RingElement create(); bool hasToken(...); void release(...); };


