This week has been a busy week in CSC148. In our labs, because many of us could not figure out the LinkedList problem, we had another chance to tackle it. This time, we were given hints as to how to implement LinkedList into class Queue. In trying to solve the Queue problem, we figured out ways to write the __len__, __delitem__, __setitem__, and insert methods for class LinkedList. A couple things I learned from this lab was that, in Queue, the front and back of the Queue were initialized as two separate empty items themselves, rather than try to figure out from a non-empty Queue which item was in front and which item was in the back. This turned out rather useful as we were trying to index the Queue earlier on but had difficulty in enqueueing and dequeueing items this way. Creating the two attributes (self._back, self._front) was much easier in completing the tasks.
Another thing that we had been working on this week was the assignment for regular expressions (regex). We were to write separate classes for each of the different regular expressions. I decided to write a basic regex class, called Regex, from which the other classes would inherit properties. I then made four other subclasses of Regex, called LineRegex, DotRegex, StarRegex and LeafRegex. Each will have an __init__ method, a __repr__ method, and an __eq__ method. Though a LineRegex and a DotRegex are similar in properties, I decided to write them as two different classes because they have different ways of being equivalent to another Regex.
No comments:
Post a Comment