In the first three weeks of class we studied classes and subclasses. This has not been too difficult for me; I think these concepts are logical. This past Thursday the first assignment was due, which I worked on alone.
There is something interesting I did with my implementation of the assignment. This has to do with the __init__ method of the GameView class. While writing it, I was trying to think of what attributes a GameView should have. The answer I came up with was: which game is being played. But the identity of the game is in fact another class! So my GameView class has a single attribute Game, which is capitalized because it is an attribute which represents a class. If a GameView gv is initialized with the SubtractSquareState class, for instance, calling gv.Game() will initialize a SubtractSquareState, as if SubtractSquareState() was called. Of course, there are plenty of other ways to accomplish this, but I was curious whether this would work. It did, so I left it in.
As for week 4, we have started learning about recursion. This is more tricky than the material of the first three weeks, but I think I understand it. Next week is the first test, which I am optimistic about.
No comments:
Post a Comment