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 XXXXXXXXXXXXXXXXXXXXdrop pieces in even columns to start dropping piece b b a in column  XXXXXXXXXXb.... b.... a....  drop complete XXXXXXXXXXb.... b.... a....  dropping piece b c a in column  XXXXXXXXXXb.b.. b.c.. a.a..  drop complete XXXXXXXXXXb.b.. b.c.. a.a..  dropping piece b b c in column  XXXXXXXXXXb.b.b b.c.b a.a.c  drop complete XXXXXXXXXXb.b.b b.c.b a.a.c  dropping piece b b b in column  XXXXXXXXXXb.bbb b.cbb a.abc  5 blocks will be removed XXXXXXXXXXb.... b.c.b a.a.c  drop complete XXXXXXXXXXb.... b.c.b a.a.c  dropping piece a a b in column  XXXXXXXXXXb..a. b.cab a.abc  drop complete XXXXXXXXXXb..a. b.cab a.abc  dropping piece a c b in column  XXXXXXXXXXba.a. bccab ababc  drop complete XXXXXXXXXXba.a. bccab ababc  dropping piece c c a in column XXXXXXXXXXc ....c ba.aa bccab ababc  3 blocks will be removed XXXXXXXXXXc ba..c bc.ab abcbc  drop complete XXXXXXXXXXc ba..c bc.ab abcbc  dropping piece c b c in column XXXXXXXXXXc.c bab.c bccab abcbc  drop complete XXXXXXXXXXc.c bab.c bccab abcbc  Test second block manager create empty block manager with 10 rows, 8 cols, 5 block types ........ ........ ........ ........ ........ ....... XXXXXXXXXXXXXXXXXXXXdrop pieces in even columns to start dropping piece d e e in column 0 ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd XXXXXXXXXXe XXXXXXXXXXe XXXXXXXXXXdrop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd XXXXXXXXXXe XXXXXXXXXXe XXXXXXXXXXdropping piece c c d in column 2 ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c..... e.c..... e.d.....  drop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c..... e.c..... e.d.....  dropping piece a e a in column 4 ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c.a... e.c.e... e.d.a...  drop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c.a... e.c.e... e.d.a...  dropping piece a d b in column 6 ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c.a.a. e.c.e.d. e.d.a.b.  drop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c.a.a. e.c.e.d. e.d.a.b.  dropping piece a a e in column 5 ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c.aaa. e.c.ead. e.d.aeb.  5 blocks will be removed  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c..... e.c...d. e.d.eeb.  drop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c..... e.c...d. e.d.eeb.  dropping piece a a e in column 3 ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.ca.... e.ca..d. e.deeeb.  3 blocks will be removed  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c..... e.ca..d. e.da..b.  drop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c..... e.ca..d. e.da..b.  dropping piece c c c in column 6 ........ ... XXXXXXXXXXXXXXXXXXXXc XXXXXXXXXXc. d.c...c. e.ca..d. e.da..b.  3 blocks will be removed  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c..... e.ca..d. e.da..b.  drop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c..... e.ca..d. e.da..b.  dropping piece d a c in column 4 ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c.d... e.caa.d. e.dac.b.  drop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c.d... e.caa.d. e.dac.b.  dropping piece c c a in column 3 ........  XXXXXXXXXXXXXXXXXXXXc XXXXXXXXXXc.... d.cad... e.caa.d. e.dac.b.  3 blocks will be removed  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.c.d... e.cca.d. e.dcc.b.  3 blocks will be removed  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd XXXXXXXXXXe.c.d.d. e.dca.b.  drop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd XXXXXXXXXXe.c.d.d. e.dca.b.  dropping piece a b d in column 7 ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd......a e.c.d.db e.dca.bd  drop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd......a e.c.d.db e.dca.bd  dropping piece d a b in column 5 ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd....d.a e.c.dadb e.dcabbd  3 blocks will be removed  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd XXXXXXXXXXe.c.da.a e.dcabbb  3 blocks will be removed  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd XXXXXXXXXXe.c.d... e.dcaa.a  drop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd XXXXXXXXXXe.c.d... e.dcaa.a  dropping piece e e e in column 1 ........ ........ ...... XXXXXXXXXXXXXXXXXXXXde...... eec.d... eedcaa.a  3 blocks will be removed  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd XXXXXXXXXXe.c.d... e.dcaa.a  drop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd XXXXXXXXXXe.c.d... e.dcaa.a  dropping piece b b a in column 6 ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd.....b. e.c.d.b. e.dcaaaa  4 blocks will be removed  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd XXXXXXXXXXe.c...b. e.dcd.b.  drop complete  ........ ........ ...... XXXXXXXXXXXXXXXXXXXXd XXXXXXXXXXe.c...b. e.dcd.b.  test first manager again XXXXXXXXXXc.c bab.c bccab abcbc  dropping piece a b a in column XXXXXXXXXXa. ..cbc babac bccab abcbc  drop complete XXXXXXXXXXa. ..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 XXXXXXXXXXcb.a. bb.bc babac bccab abcbc  3 blocks will be removed XXXXXXXXXXb.a. .b.bc .abac cccab abcbc  3 blocks will be removed XXXXXXXXXXa. .b.bc .b.ac .abab abcbc  3 blocks will be removed XXXXXXXXXXac .b.bc .a.ab abcac  drop complete XXXXXXXXXXac .b.bc .a.ab abcac 


Answered 2 days AfterMay 03, 2021

Solution

Rushendra answered on May 06 2021
28 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Submit New Assignment

Copy and Paste Your Assignment Here