Closed acrm closed 7 years ago
Additional Task 1: Tests
Make tests for each collection in such form:
var myList = new MyList
var resultValues = new List
if(resultValues[0] = 1 && resultValues[1] = 3 && resultValues[2] = 5) //pass else //fail
Additional Task 2: Nested classes Move definitions of enumerator classes inside corresponding collection classes and change enumerators classes constructors such way, that now they consume a reference to collection instance itself instead of instaces inner collection. (Nested classes have access to all private members of nesting class)
Our enumerators work fine, by they don't give us a lot of advantages. By now it's just another way to enumerate collection items and it's actually more noisy that simple use of cycles. May be it gives some level of abstraction over collections but now it's not help us much. But our My-interfaces are just models of built-in IEnumerator and IEnumerable interfaces for .NET standard libraries. And for that built-in interfaces C# language has bult-in supportive syntax, that makes use of classes implemented these interfaces much handy.
In details:
Nice done! Now can merge to master
Define IMyEnumerable interface with following member:
Create nested class MyListEnumerator , implemented IMyEnumerator for the instance of MyList collection, given in constructor parameter
Implement in the MyList class IMyEnumerable interface
Do the same for MyStack and MyLinkedList classes