Boost your Grades with us today!

Computer Science Question

Make the following changes to your video game code (or the code from lab #5 answer):

  1. Let’s make the game more playable! Currently, the player wins every other round and each game consists of a single turn. We want to change this! Create a new global variable named computerHealth and initialize it to 100. Inside the loop that represents a single game being played, place another loop. This loop will represent a single round of a game. In each iteration of the inner loop:
    • The computer will attack the player for a value between 0 and 50.
    • The player will choose an action (heal, block, special, or regular)
    • Make the calculated adjustments to computerHealth and playerHealth
      • If the player health goes below 0, count it as a player loss and break out of the inner loop.
      • If the computer health goes below 0, count it as a player win and break out of the inner loop.
      • Otherwise, the inner loop will iterate again (i.e. the computer will attack and the player will pick another action).
    • You can remove the previous logic of determining a winner based on if it’s an even or odd round.
  2. Update the block function to “return” two values. It should have one value parameter (computerDamage from before) and two reference parameters (named blockAmount and hitAmount). The function should calculate how much of the attack the user blocks. To do this, select a random number between 0 and computerDamage and assign it to blockAmount. After determining how much of computerDamage is blocked, assign the rest to hitAmount. In main, print the value of each (we will have access to both since the arguments will be passed by reference).
  3. Update your program so that when the user decides to quit, it saves the number of wins and losses to a file. When the program starts, load the data (if it exists). When the program ends, overwrite the previous data with the updated data. You can simply put the number of wins in the first line of the file and the number of losses in the second line.


15% off for this assignment.

Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!

Why US?

100% Confidentiality

Information about customers is confidential and never disclosed to third parties.

Timely Delivery

No missed deadlines – 97% of assignments are completed in time.

Original Writing

We complete all papers from scratch. You can get a plagiarism report.

Money Back

If you are convinced that our writer has not followed your requirements, feel free to ask for a refund.