- The first week's lectures covered the design of new classes. For instance, we analyzed a situation (class Point) to figure out what to call our object, and what methods we needed to implement within the class to manipulate the object. Exercise One from that week, the one with class Dog and class Toy, familiarized me with classes; including how to use the __init__ method to create attributes and how to call other classes' methods.
- The second week's lectures covered the creation of abstract data types (ADTs). A clever example from the Monday lecture described a Stack ADT as a stack of rocks; where you may add to the stack by adding rocks to the top (push), and you can only remove the rock at the top of the Stack (pop). The week ended with comprehensions and the ternary if, which I will need to look at a bit more to understand them because I honestly didn't pay enough attention in class.
- The third week's lectures started with the creation of subclasses with the format: class NewClass(OldClass):. Then prof Heap explained how to raise your own exceptions. Finally, he went over how to use the __eq__ method to see if stack objects have the same items in the same order, and the __repr__ method. The __repr__ method was new for me but looked like a fairly simple way to represent a class. The lab for week three helped me understand how to create ADTs such as class Queue, where items come and go at a first come first served basis, rather than the way Stack pushes and pops items.
*Note to self: work on comprehensions, ternary if, exceptions, __repr__ method.
No comments:
Post a Comment