Question: Hey, can someone help me with this simple question? Just create a class, ignore the question 3 folder thing. Thanks a lot! Open the project

Hey, can someone help me with this simple question? Just create a class, ignore the question 3 folder thing.

Thanks a lot!

Hey, can someone help me with this simple question? Just create a

Open the project in the folder Q3, and create a BuildingBlocks class that implements the required rules described below (and also in README.TXT file) Building Blocks is a single-player game. The rules are as follows: Upon creation of the game, a maximum tower height is set. This maximum height is not disclosed to the person playing the game On each turn you can add blocks to the tower If you exceed the maximum tower height, the tower falls and its height is reset to zero The player's score at any time is the current height of the tower divided by the number of turns taken. The score is initially zero. At any time the player can reset their height and turns to zero Your task is to create a BuildingBlocks class that implements these rules It should include the following public methods A constructor BuildingBlocks(int maxTowerHeight) which starts a new game with the given maximum tower height. Accessor methods: getScoreO returns your current score (use integer division) getHeight0 returns the current height of the tower getTurnsO returns the number of turns taken by the player Mutator methods: addBlocks(int numBlocks) adds the given number of blocks to the tower. This method should return a boolean that is true if the action is successful (i.e. the tower doesn't collapse) and false otherwise. - reset0 resets the score, height and number of turns to zero to start a new game. Example BuildingBlocks blocksnew BuildingBlocks (10) blocks.addBlocks (3) /successful, returns true blocks.getHeight /7 returns 3 blocks.addBlocks (3) / successful, returns true blocks.getHeight// returns6 blocks.getTurns ); blocks.getScoreO blocks.addBlocks (6)// too high > 10 - returns false blocks.getHeight// returns blocks.getScore ) blocks.getTurnsO blocks.reset ) // returns 2 // returns 3-6/2 // returns 0 // returns 3 // sets turns, score, height to zero End

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!