Homework 7

Due: November 15th, 2021 12:00pm

Note: HW7 builds off of HW6


Scenario: You’ve made your classes. The contestants. The Codémon. The items. The skills. Now, we need to implement a few more things to our classes so that we can start working on our battle simulator. (This assignment involves a little RNG, so use the random seed of 11.) Here is how it will work: Each battle will be a 1v1 encounter between 2 contestants. Each contestant’s Codémon will be shuffled, and then be pitted against each other. Taking turns (starting with the coach with the louder voice), The first codemon on each player’s team that has not been sent into a coma will attack the first Codémon on their opponents team that has also not been sent into a coma. A Codémon can be described as “comatose” once their health reaches 0. To attack, a codemon will randomly select one of their skills, and deal that skill's damage to the first non-comatose Codémon in their opponent's party. Remember, a comatose pokemon cannot attack. A winner is determined as the Codémon coach who did not run out of Codémon. You will need to make the following additions to your program:

  1. You must create a new templated class called queue. A queue is a basic ‘First In First Out’ data structure, kind of like a line at walmart. For now, this class will mainly be used to form a line of contestants looking to compete. It should have 2 private member variables, an integer to represent how many objects of type T are in the queue, and an array of no more than 100 objects of type T. It should also have the following public member functions:
    • pushBack() - add an object of type T to the back of the queue.
    • popFront() - return the object at the front of the queue, and remove that object.
    • peek() - return the object at the front of the queue.
  2. Add a new member variable to your Contestant class called volume. This should be an integer between 0 and 100. The contestant with the higher volume in a fight will be the one to take their turn first. When calling your default constructor and your parameterized constructor, randomize their volume.
  3. Overload the * (multiplication) operator for the Contestant class. This operator will serve as the function that allows 2 contestants to “battle”. It should return a contestant, the winner of the battle.
  4. Overload the + and += operators for a Contestant and a Codémon. If a Codémon is added to a Contestant, that Codémon should be added to that Contestants party, if they have not already reached the maximum number of Codémon. If they have already reached the maximum, add it to their party anyway, and immediately remove the Codémon with the lowest level from their party (pick one at random if there is a tie.)
  5. Overload the - and -= operators for a Contestant and a Codémon. This overload should remove a Codémon from the Contestants party. If the Codémon does not exist in the contestants party, simply output a message stating that the Codémon could not be removed as it does not exist.
  6. These operators (+, +=, -, and -=) must also be implemented to add an Item to a Contestant. If you try to add an item to a contestant whose backpack is full, simply do not give them the item.
  7. Give your Codémon class a static member variable to represent the weather. There are 5 possible weather conditions: “None”, “Sunny”, “Hail”, “Snow”, and “Rain”. Each weather condition has the following effects:
    1. None: No effect
    2. Sunny: All damage dealt in combat is doubled.
    3. Hail: At the end of each player’s turn, the first 2 non-comatose Codémon for BOTH coaches lose 1/16 of their health, rounded down. (So, if player 1 goes first and it is hailing, it would go player 1 turn, then hail damage, then player 2 turn, then hail damage, etc.)
    4. Snow: All damage dealt in combat is halved.
    5. Rain: All attacks have a 50% chance to “miss” (deal 0 damage).
    The weather should be set randomly (each weather status has an equal chance) when 2 Codémon coaches go into battle with each other.
  8. Give your Codémon class a new member variable,to represent its current health. When a Codémon object is constructed, it’s current health should be set equal to its HP.
  9. Overload the () operator for both your Codémon and your Contestant class to take 1 string parameter. In your Codémon class, if the parameter reads “heal”, set its current health equal to its maximum health. In your Contestant class, if the parameter reads “heal”, fully heal all of the Codémon of that contestant.

And…. that’s it! In your main program, to make sure everything is working properly, do the following things: