Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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!
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 EndStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started