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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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.

 

 

80 3 2
55 4 1
30 20 1
Input
p 60 14
b 100 12
b 35 25
1.3
steel
wood
Output
-5
15
10
Transcribed Image Text:80 3 2 55 4 1 30 20 1 Input p 60 14 b 100 12 b 35 25 1.3 steel wood Output -5 15 10
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY