Practice with I/O and object-oriented programming in Python.
Beginning of class session 7.
PythonObjects
, from your SVN repository. All your work for this assignment should be done within that project. Put your code in the appropriate *.py
files given.
wacky.py
in the PythonFunctions
project into wacky_loop.py
in the PythonObjects
project.
Add a "read-eval-print" loop to your Wacky Prof. Quotes program so a user can interact with your program to add quotes and display quotes. A sample interaction is shown below:
Enter 'a' to add a quote, 'p' to print quotes, and 'q' to quit: a Who spaketh the wackiness? Curt When did they speak thusly? 1/19/2007 What sayeth they? SQL doesn't support +=, but O+= does represent the starship Enterprise. Enter 'a' to add a quote, 'p' to print quotes, and 'q' to quit: a Who spaketh the wackiness? Matt When did they speak thusly? 10/15/2005 What sayeth they? Today is Tuesday. It's today! Enter 'a' to add a quote, 'p' to print quotes, and 'q' to quit: a Who spaketh the wackiness? Curt When did they speak thusly? 11/3/2006 What sayeth they? That's probably harsh and uncaring, but it's funny. Enter 'a' to add a quote, 'p' to print quotes, and 'q' to quit: p Whom do you seek? Curt Curt's record of wackiness: On 1/19/2007: SQL doesn't support +=, but O+= does represent the starship Enterprise. On 11/3/2006: That's probably harsh and uncaring, but it's funny. Enter 'a' to add a quote, 'p' to print quotes, and 'q' to quit: p Whom do you seek? Matt Matt's record of wackiness: On 10/15/2005: Today is Tuesday. It's today! Enter 'a' to add a quote, 'p' to print quotes, and 'q' to quit: q Thanks for playing.
Your program does not have to work exactly like the example, just similarly.
pickle
module for this.
'rb'
and 'wb'
.
A basic Tetris program is included in the project. You can run it by executing the Tetris.py
module. The enter and arrow keys control the game.
The Bar
class is partially implemented for you.
Bar
by implementing the methods moveLeft
, moveRight
, and rotate
. You might find the moveDown
method is a good example.
MrChunky
, Tee
, LeftZag
, RightZig
, Ell
, and Jay
, which extend
Bar
. To do this you should study, and perhaps refactor, Bar
. Your goal is to minimize the six subclasses while keeping the code sensible.
Comments in each of the classes specify the shapes and their behavior. You can run a module declaring a piece class separately to unit test it, or run TetrisTextTests.py
to run all the unit tests.
The behavior of the pieces may not exactly match your favorite version of Tetris. Sorry about that, but you need to pass the given unit tests.
Turn-in your work by committing it to your SVN repository.