CS 251 Intermediate Programming Columns Game: Part 1 – Block Manager Brooke Chenoweth Spring 2020 In this lab, you will begin work on the columns game. You will be working on internal logic and...

1 answer below »
CS 251 Intermediate Programming Columns Game: Part 1 – Block Manager Brooke Chenoweth Spring 2020 In this lab, you will begin work on the columns game. You will be working on internal logic and bookkeeping independent of the game GUI which you will write in the next assignment. Game Description You will be creating a game similar to Columns.1 As the game progresses, columns of three different symbols (such as differently-colored blocks) appear, one at a time, at the top of the playing area and fall to the bottom, landing either on the floor or on top of previously-fallen “columns”. While a column is falling, the player can move it left and right, and can also cycle the positions of the symbols within it. After a column lands, if three or more of the same symbols are connected in a horizontal, vertical, or diagonal line, those symbols disappear. The pile of columns then settles under gravity. If this resettlement causes three or more other symbols to align, they too disappear and the cycle repeats. Problem Specification You are going to create a BlockManager class to handle your block bookkeeping. You will demonstrate it’s functionality in a BlockManagerTest class. (You likely will want some additional classes/interfaces to accomplish this, but I leave that design up to you.) The BlockManager should be independent of any future GUI code. BlockManager Although the actual game will have a fixed board size, your class should be able to handle arbitrary positive values for the number of rows and columns. Your class must provide the following functionality. • Construct a new manager with given number of rows and columns. 1See https://en.wikipedia.org/wiki/Columns_(video_game) 1 • Generate random column pieces using some number of symbols. – The final game will use random pieces, but for this test program you should have reproducible results each time it is run. – One simple way to have “random” behaviour that can be repeated is to use a Random object that has been initialized with a fixed seed. • Override toString to provide a string representation of your board. • Add a new piece to the board in a specific column position. Determine which blocks will be part of a horizontal, vertical, and/or diagonal line of at least 3 blocks of the same color. • Remove blocks from the board and drop pieces. – Given a line (or lines) of matching blocks, remove them from the board. – Any blocks above the removed blocks should fall down to fill the empty space. – Check for any matching lines formed as a result. BlockManagerTest The purpose of this testing class is to demonstrate to us that your block manager works correctly, so you need to put it through its paces. • You should create at least two BlockManager objects with separate sizes and symbols. Demonstrate that they operate independently of each other. (I want to make sure that you aren’t locked in to just one configuration and that you aren’t making things static inappropriately.) • Test adding columns and dropping blocks on each manager. – Print out the string representation of the manager before you begin. – Add a new piece to the board. 1. Print out the block manager after the addition. 2. Print out how many blocks are in lines and should be removed. (May be zero if there are no lines formed by the drop.) 3. Remove the matching lines and drop blocks. 4. Print out the resulting block manager. 5. Print out how many blocks need to be removed as a result of new matching lines formed by the dropped blocks. 6. Repeat from 3 until no more matches are formed. 7. Add more pieces. Don’t use the same position or piece every time. Demonstrate horizontal, vertical, and diagonal matches. Demonstrate lines formed by dropped blocks. 2 – After demonstrating each manager, repeat the tests with the first manager again to prove that it is independent of the second. • Don’t just copy and paste the same test code for each manager. Structure your code sensibly with methods rather than writing one giant main method. • Your testing output should come from BlockManagerTest, not BlockManager. Don’t put console output in the middle of your block manager logic. I am providing you with example output from my testing code to give you an idea what I’m expecting this to look like.
Test first block manager create empty block manager with 6 rows, 5 cols, 3 block types ..... ..... ..... ..... ..... .....  drop pieces in even columns to start dropping piece b b a in column 0 ..... ..... ..... b.... b.... a....  drop complete  ..... ..... ..... b.... b.... a....  dropping piece b c a in column 2 ..... ..... ..... b.b.. b.c.. a.a..  drop complete  ..... ..... ..... b.b.. b.c.. a.a..  dropping piece b b c in column 4 ..... ..... ..... b.b.b b.c.b a.a.c  drop complete  ..... ..... ..... b.b.b b.c.b a.a.c  dropping piece b b b in column 3 ..... ..... ..... b.bbb b.cbb a.abc  5 blocks will be removed  ..... ..... ..... b.... b.c.b a.a.c  drop complete  ..... ..... ..... b.... b.c.b a.a.c  dropping piece a a b in column 3 ..... ..... ..... b..a. b.cab a.abc  drop complete  ..... ..... ..... b..a. b.cab a.abc  dropping piece a c b in column 1 ..... ..... ..... ba.a. bccab ababc  drop complete  ..... ..... ..... ba.a. bccab ababc  dropping piece c c a in column 4 ..... ....c ....c ba.aa bccab ababc  3 blocks will be removed  ..... ..... ....c ba..c bc.ab abcbc  drop complete  ..... ..... ....c ba..c bc.ab abcbc  dropping piece c b c in column 2 ..... ..... ..c.c bab.c bccab abcbc  drop complete  ..... ..... ..c.c bab.c bccab abcbc  Test second block manager create empty block manager with 10 rows, 8 cols, 5 block types ........ ........ ........ ........ ........ ........ ........ ........ ........ ........  drop pieces in even columns to start dropping piece d e e in column 0 ........ ........ ........ ........ ........ ........ ........ d....... e....... e.......  drop complete  ........ ........ ........ ........ ........ ........ ........ d....... e....... e.......  dropping piece c c d in column 2 ........ ........ ........ ........ ........ ........ ........ d.c..... e.c..... e.d.....  drop complete  ........ ........ ........ ........ ........ ........ ........ d.c..... e.c..... e.d.....  dropping piece a e a in column 4 ........ ........ ........ ........ ........ ........ ........ d.c.a... e.c.e... e.d.a...  drop complete  ........ ........ ........ ........ ........ ........ ........ d.c.a... e.c.e... e.d.a...  dropping piece a d b in column 6 ........ ........ ........ ........ ........ ........ ........ d.c.a.a. e.c.e.d. e.d.a.b.  drop complete  ........ ........ ........ ........ ........ ........ ........ d.c.a.a. e.c.e.d. e.d.a.b.  dropping piece a a e in column 5 ........ ........ ........ ........ ........ ........ ........ d.c.aaa. e.c.ead. e.d.aeb.  5 blocks will be removed  ........ ........ ........ ........ ........ ........ ........ d.c..... e.c...d. e.d.eeb.  drop complete  ........ ........ ........ ........ ........ ........ ........ d.c..... e.c...d. e.d.eeb.  dropping piece a a e in column 3 ........ ........ ........ ........ ........ ........ ........ d.ca.... e.ca..d. e.deeeb.  3 blocks will be removed  ........ ........ ........ ........ ........ ........ ........ d.c..... e.ca..d. e.da..b.  drop complete  ........ ........ ........ ........ ........ ........ ........ d.c..... e.ca..d. e.da..b.  dropping piece c c c in column 6 ........ ........ ........ ........ ........ ......c. ......c. d.c...c. e.ca..d. e.da..b.  3 blocks will be removed  ........ ........ ........ ........ ........ ........ ........ d.c..... e.ca..d. e.da..b.  drop complete  ........ ........ ........ ........ ........ ........ ........ d.c..... e.ca..d. e.da..b.  dropping piece d a c in column 4 ........ ........ ........ ........ ........ ........ ........ d.c.d... e.caa.d. e.dac.b.  drop complete  ........ ........ ........ ........ ........ ........ ........ d.c.d... e.caa.d. e.dac.b.  dropping piece c c a in column 3 ........ ........ ........ ........ ........ ...c.... ...c.... d.cad... e.caa.d. e.dac.b.  3 blocks will be removed  ........ ........ ........ ........ ........ ........ ........ d.c.d... e.cca.d. e.dcc.b.  3 blocks will be removed  ........ ........ ........ ........ ........ ........ ........ d....... e.c.d.d. e.dca.b.  drop complete  ........ ........ ........ ........ ........ ........ ........ d....... e.c.d.d. e.dca.b.  dropping piece a b d in column 7 ........ ........ ........ ........ ........ ........ ........ d......a e.c.d.db e.dca.bd  drop complete  ........ ........ ........ ........ ........ ........ ........ d......a e.c.d.db e.dca.bd  dropping piece d a b in column 5 ........ ........ ........ ........ ........ ........ ........ d....d.a e.c.dadb e.dcabbd  3 blocks will be removed  ........ ........ ........ ........ ........ ........ ........ d....... e.c.da.a e.dcabbb  3 blocks will be removed  ........ ........ ........ ........ ........ ........ ........ d....... e.c.d... e.dcaa.a  drop complete  ........ ........ ........ ........ ........ ........ ........ d....... e.c.d... e.dcaa.a  dropping piece e e e in column 1 ........ ........ ........ ........ ........ ........ ........ de...... eec.d... eedcaa.a  3 blocks will be removed  ........ ........ ........ ........ ........ ........ ........ d....... e.c.d... e.dcaa.a  drop complete  ........ ........ ........ ........ ........ ........ ........ d....... e.c.d... e.dcaa.a  dropping piece b b a in column 6 ........ ........ ........ ........ ........ ........ ........ d.....b. e.c.d.b. e.dcaaaa  4 blocks will be removed  ........ ........ ........ ........ ........ ........ ........ d....... e.c...b. e.dcd.b.  drop complete  ........ ........ ........ ........ ........ ........ ........ d....... e.c...b. e.dcd.b.  test first manager again ..... ..... ..c.c bab.c bccab abcbc  dropping piece a b a in column 3 ..... ...a. ..cbc babac bccab abcbc  drop complete  ..... ...a. ..cbc babac bccab abcbc  dropping piece c b c in column 0 c.... b..a. c.cbc babac bccab abcbc  drop complete  c.... b..a. c.cbc babac bccab abcbc  dropping piece b b c in column 1 cb... bb.a. cccbc babac bccab abcbc  3 blocks will be removed  ..... cb.a. bb.bc babac bccab abcbc  3 blocks will be removed  ..... .b.a. .b.bc .abac cccab abcbc  3 blocks will be removed  ..... ...a. .b.bc .b.ac .abab abcbc  3 blocks will be removed  ..... ..... ...ac .b.bc .a.ab abcac  drop complete  ..... ..... ...ac .b.bc .a.ab abcac




Answered 2 days AfterMay 03, 2021

Answer To: CS 251 Intermediate Programming Columns Game: Part 1 – Block Manager Brooke Chenoweth Spring 2020 In...

Rushendra answered on May 06 2021
144 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here