Write a program that calculates the damage inflicted by a weapon against a target. The user will first enter the hit point of the target as well as its bludgeoning (ezici) armor and piercing (delici) armor, all as integers. Then the type of the weapon will be given as a char followed by the durability and damage of the weapon both as integers. The type of the weapon can EITHER be ‘b’ representing bludgeoning or ‘p’ representing piercing weapon. Based on the type, the user will give a final input; if it is a bludgeoning weapon, a material value as a string; if it is a piercing weapon, a thickness value as a double. After getting all this input, the program will simulate 5 consecutive attacks at the target with the given weapon and print out the final hit point of the target as an integer. The attack works differently for the type of the weapon as below and after each attack the weapon can be destroyed: If it is a bludgeoning weapon: dmg= (weapon damage-bludgeoning armor ) After each attack, the durability of a bludgeoning weapon is decreased based on the material of the weapon By bludgeoning armor/2, if the material is wood By bludgeoning armor/4, if the material is steel By bludgeoning armor/3, if the material is anything else If it is a piercing weapon: dmg= (weapon damage-piercing armor)*thickness+momentum After each attack, the durability of a piercing weapon is decreased by TWICE the piercing armor. Also, the momentum is increased by 1 (momentum starts at 0 in the first attack). After each attack if the durability becomes 0 or lower, the weapon cannot make any more attacks. Requirements: You should define and use a class for the weapon, two CHILD classes of the weapon class for BOTH the bludgeoning weapon and piercing weapon. All weapon related information should be kept as protected inside the class. All bludgeoning weapon specific information should be kept as private inside the class. All piercing weapon specific information should be kept as private inside the class. Classes should take the related input in their constructor functions. The base weapon class MUST have a virtual function for attack. The child classes MUST override this virtual function according to their attack functionality. The objects defined in the main MUST be kept in the heap.
c++
Assignment
Write a program that calculates the damage inflicted by a weapon against a target. The user will first enter the hit point of the target as well as its bludgeoning (ezici) armor and piercing (delici) armor, all as integers. Then the type of the weapon will be given as a char followed by the durability and damage of the weapon both as integers.
The type of the weapon can EITHER be ‘b’ representing bludgeoning or ‘p’ representing piercing weapon. Based on the type, the user will give a final input; if it is a bludgeoning weapon, a material value as a string; if it is a piercing weapon, a thickness value as a double.
After getting all this input, the program will simulate 5 consecutive attacks at the target with the given weapon and print out the final hit point of the target as an integer. The attack works differently for the type of the weapon as below and after each attack the weapon can be destroyed:
- If it is a bludgeoning weapon: dmg= (weapon damage-bludgeoning armor )
After each attack, the durability of a bludgeoning weapon is decreased based on the material of the weapon
-
- By bludgeoning armor/2, if the material is wood
- By bludgeoning armor/4, if the material is steel
- By bludgeoning armor/3, if the material is anything else
- If it is a piercing weapon: dmg= (weapon damage-piercing armor)*thickness+momentum
After each attack, the durability of a piercing weapon is decreased by TWICE the piercing armor. Also, the momentum is increased by 1 (momentum starts at 0 in the first attack).
- After each attack if the durability becomes 0 or lower, the weapon cannot make any more attacks.
Requirements:
- You should define and use a class for the weapon, two CHILD classes of the weapon class for BOTH the bludgeoning weapon and piercing weapon.
- All weapon related information should be kept as protected inside the class.
- All bludgeoning weapon specific information should be kept as private inside the class.
- All piercing weapon specific information should be kept as private inside the class.
- Classes should take the related input in their constructor functions.
- The base weapon class MUST have a virtual function for attack.
- The child classes MUST override this virtual function according to their attack functionality.
- The objects defined in the main MUST be kept in the heap.
Step by step
Solved in 2 steps