11HW2Tetris

11HW2Tetris - CS108, Stanford Winter 2010 Handout #11 Young...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CS108, Stanford Handout #11 Winter 2010 Young HW2 Tetris Assignment by Nick Parlante For HW2 you will build up a set of classes for Tetris. This assignment emphasizes the basic Divide and Conquer strength of OOP design -- using encapsulation to divide a big scary problem into several slightly less scary and independently testable problems. Tetris is a large project, so the modular OOP design matters. Part A of the project sets up the Piece class. Part B builds the Board class, and Part C adds on some other fun bits. There are two due dates. . • Monday January 18th (11:59pm) -- "draft" functional version of Part A with a Piece implementation. In particular, getPieces() should return an array of Piece objects. The Piece objects should implement getWidth(), getSkirt(), computeNextRotation(), and fastRotation() correctly. You should have at least some Piece unit tests. If the code has some problems -- some of the pieces are wrong, some methods don't work -- that's ok, just turn it in anyway. This is just an informal midway checkpoint for your own benefit, and we're not really going to look at it. • Monday January 25th -- everything is done and works. This is the version we will really grade. For reasons that will become clear later, there is a theme of efficiency in this design. We are not just writing classes that implement Tetris. We are writing classes that implement Tetris quickly .
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 For us old-timers who grew up before the popularization of Doom and Quake, Tetris is one of the coolest things around. Try playing it for 27 hours and see if you don't agree. If you play Tetris enough, you may begin to have Tetris dreams (http://www.sciam.com/article.cfm? articleID=0001F172-55DA-1C75- 9B81809EC588EF21, or just type "tetris dreams" into Google). Part A -- Piece There are seven pieces in standard Tetris. The Stick (also known as "the long skinny one") The L and its mirror L2 The S and its mirror S2 The Square The Pyramid Each standard piece is composed of four blocks. The two "L" and "S" pieces are mirror images of each other, but we'll just think of them as similar but distinct pieces. A chemist might say that they where "isomers" or more accurately "enantiomers" (note: I only looked that word up in an effort to make the handout more impressive.). A piece can be rotated 90 degrees counter-clockwise to yield another piece. Enough rotations get you back to the original piece — for example rotating an S twice brings you back to the original state. Essentially, each tetris piece belongs to a family of between one and four distinct rotations. The square has one, the S's have two, and the L's have four. For example, here are the four rotations (going counter-clockwise) of the L:
Background image of page 2
3 Our abstraction will be that a piece object represents a single Tetris piece in a single rotation, so the above diagram shows four different piece objects. Body
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

11HW2Tetris - CS108, Stanford Winter 2010 Handout #11 Young...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online