Task 1: Weapons (6 marks) In order to survive in the Hungry Games, our tributes would...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Task 1: Weapons (6 marks) In order to survive in the Hungry Games, our tributes would need to be well versed with different weapons. In order to do so, we would need a magical spell from which we can create weapons of varying capabilities. a. Create a class, Weapon, inherited from the Thing class. The constructor should take in 3 parameters, the name of the weapon, min_dmg and max_dmg, which describes the damage capabilities of the weapon. Note that the name of the weapon is the type of the weapon in string, so multiple weapons may share the same name because they are of the same type. >>> sword = Weapon ("sword", 3, 10) >>> isinstance (sword, Weapon) True >>> isinstance (sword, Thing) True b. Implement the methods, min_damage () and max_damage(), which would return the minimum and maximum damage for a weapon respectively. >>> sword.min_damage () 3 >>> sword.max_damage () 10 c. Implement a method, damage (), which would return a value between min_dmg and max_dmg inclusive. HINT: You may use the random.randint(min, max) method to generate a random integer between min and max inclusive. >>> sword. damage () # Should return a value between 3 and 10 5 Task 2: Ammunition (4 marks) As melee weapons require the user to be up close before they can damage the enemy, being only skilled with melee weapons would expose our tributes to additional threats. It is thus important that we have ranged weapons. However, the biggest drawback of ranged weapons is that they require a supply of ammo in order to be effective. Sure, you can try and hit someone with your bow, but clearly that would not be very smart... In this task, we will model the ammunition with the Ammo class. a. Create a class Ammo, inherited from the Thing class. The constructor should take in 3 parameters, the name of the ammo, the weapon that this ammo is for, as well as the quantity of this ammo (which is the number of shots avaliable initially). CS1010A, Semester I, 2023/2024-Mission 12 3 b. Create a method get_quantity (), that would return the number of shots available in this ammo object. c. Create a method weapon_type(), that would return the name of the type of the weapon that this ammo is supposed to work with. Recall that a weapon's type is simply its name. Hence an ammo can work with different weapon objects as long as they share the same name. d. Create a method remove_all(), that would set the number of shots in the ammo to be 0. Task 3: Ranged Weapon (8 marks) Now that we have a way to create Ammo, it is now time to create a Ranged Weapon. The RangedWeapon class will be a subclass of the Weapon class. a. Create a class RangedWeapon, which inherits from the Weapon class. The constructor should take in 3 parameters, the name of the weapon, min_dmg and max_dmg, which describes the damage capabilities of the weapon. The RangedWeapon should have a property, shots, that keeps track of the current ammo supply. A newly created RangedWeapon start with 0 shots. Note that since the type of a weapon is simply its name, it is not unusual to have multiple weapons that share the same name. >>> bow = RangedWeapon ("bow", 1, 4) >>> isinstance (bow, RangedWeapon) True >>> isinstance (bow, Weapon) True b. Create a method shots_left(), that returns the ammo supply for the current ranged weapon. c. Create a method load(ammo), that would take in an Ammo object. If the ammo object is meant for the weapon, the shots count for the weapon would be increased by the ammo's quantity, and the ammo quantity will be reduced to 0 (Hint: you can use remove_all() to set the quantity of the Ammo to 0) However, if the ammo is of the wrong type, there is no effect on either the Ammo or the RangedWeapon. d. Override the damage () method for RangedWeapon such that it behaves in the following manner: (i) Returns 0 if the ranged weapon does not have any shots left (ii) Otherwise, decrease the number of shots left by 1, and returns a value between min_dmg and max_dmg inclusive. You should call its superclass's damage () method here. Task 1: Weapons (6 marks) In order to survive in the Hungry Games, our tributes would need to be well versed with different weapons. In order to do so, we would need a magical spell from which we can create weapons of varying capabilities. a. Create a class, Weapon, inherited from the Thing class. The constructor should take in 3 parameters, the name of the weapon, min_dmg and max_dmg, which describes the damage capabilities of the weapon. Note that the name of the weapon is the type of the weapon in string, so multiple weapons may share the same name because they are of the same type. >>> sword = Weapon ("sword", 3, 10) >>> isinstance (sword, Weapon) True >>> isinstance (sword, Thing) True b. Implement the methods, min_damage () and max_damage(), which would return the minimum and maximum damage for a weapon respectively. >>> sword.min_damage () 3 >>> sword.max_damage () 10 c. Implement a method, damage (), which would return a value between min_dmg and max_dmg inclusive. HINT: You may use the random.randint(min, max) method to generate a random integer between min and max inclusive. >>> sword. damage () # Should return a value between 3 and 10 5 Task 2: Ammunition (4 marks) As melee weapons require the user to be up close before they can damage the enemy, being only skilled with melee weapons would expose our tributes to additional threats. It is thus important that we have ranged weapons. However, the biggest drawback of ranged weapons is that they require a supply of ammo in order to be effective. Sure, you can try and hit someone with your bow, but clearly that would not be very smart... In this task, we will model the ammunition with the Ammo class. a. Create a class Ammo, inherited from the Thing class. The constructor should take in 3 parameters, the name of the ammo, the weapon that this ammo is for, as well as the quantity of this ammo (which is the number of shots avaliable initially). CS1010A, Semester I, 2023/2024-Mission 12 3 b. Create a method get_quantity (), that would return the number of shots available in this ammo object. c. Create a method weapon_type(), that would return the name of the type of the weapon that this ammo is supposed to work with. Recall that a weapon's type is simply its name. Hence an ammo can work with different weapon objects as long as they share the same name. d. Create a method remove_all(), that would set the number of shots in the ammo to be 0. Task 3: Ranged Weapon (8 marks) Now that we have a way to create Ammo, it is now time to create a Ranged Weapon. The RangedWeapon class will be a subclass of the Weapon class. a. Create a class RangedWeapon, which inherits from the Weapon class. The constructor should take in 3 parameters, the name of the weapon, min_dmg and max_dmg, which describes the damage capabilities of the weapon. The RangedWeapon should have a property, shots, that keeps track of the current ammo supply. A newly created RangedWeapon start with 0 shots. Note that since the type of a weapon is simply its name, it is not unusual to have multiple weapons that share the same name. >>> bow = RangedWeapon ("bow", 1, 4) >>> isinstance (bow, RangedWeapon) True >>> isinstance (bow, Weapon) True b. Create a method shots_left(), that returns the ammo supply for the current ranged weapon. c. Create a method load(ammo), that would take in an Ammo object. If the ammo object is meant for the weapon, the shots count for the weapon would be increased by the ammo's quantity, and the ammo quantity will be reduced to 0 (Hint: you can use remove_all() to set the quantity of the Ammo to 0) However, if the ammo is of the wrong type, there is no effect on either the Ammo or the RangedWeapon. d. Override the damage () method for RangedWeapon such that it behaves in the following manner: (i) Returns 0 if the ranged weapon does not have any shots left (ii) Otherwise, decrease the number of shots left by 1, and returns a value between min_dmg and max_dmg inclusive. You should call its superclass's damage () method here.
Expert Answer:
Related Book For
Business Communication Essentials a skill based approach
ISBN: 978-0132971324
6th edition
Authors: Courtland L. Bovee, John V. Thill
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
As shown in Fig. 4.60, a horizontal beam is hinged to the wall at point A. The length of the beam is 1 = 2 m and it weighs W = 150 N. Point C is the center of gravity of the beam and it is...
-
CC10Natalie is also thinking of buying a van that will be used only for business. The cost of the van is estimated at $36,500. Natalie would spend an additional $2,500 to have the van painted. In...
-
Large-Sample Test of a 2 = ? 0 2 : When n > 30 we can test the null hypothesis that ? = ? 0 2 , or ? ? (To, by computing which is a value of a random variable whose sampling distribution is...
-
A square loop \(0.20 \mathrm{~m}\) on each side is placed in a uniform magnetic field of magnitude \(0.50 \mathrm{~T}\). The plane of the loop makes a \(30^{\circ}\) angle with the magnetic field....
-
Jokan contributes a non-depreciable asset to the Mahali LLC in exchange for a one-fourth (25%) interest in the capital, profits, and losses of the LLC. The asset has an adjusted tax basis to Jokan...
-
what happens when ou use an aggregation function in a calculated column?
-
6.2. Data has been collected from a chemical reactor. The inlet concentration was the only input variable that changed when the data was collected. The input and output data is given in Table Q6.2....
-
An option trader believes that, in the next month or so, trading conditions in an underlying are going to be very volatile. She thinks that there is a good chance that the underlying will rise...
-
7 x = 15 Change each exponential expression to an equivalent expression involving a logarithm.
-
Stan and Francine want to make perfume. In order to get the right balance of ingredients for their tastes, they bought 3 ounces of rose oil at \($2.04\) per ounce, 5 ounces of ginger essence for...
-
x 5 = 18 Change each exponential expression to an equivalent expression involving a logarithm.
-
log b 19 = 4 Change each logarithmic expression to an equivalent expression involving an exponent.
-
Determine whether the probabilities below are computed using the classical method, empirical method, or subjective method. (a) The probability of having six girls in a six-child family is 0.015625....
-
Suppose that Y=MX+b, where Y=consumption, b=consumption at zero income M=slope and Xincome. Are Yand X positively related or are they negatively related? If graphed would the curve for this equation...
-
Use the following data to answer the next two (2) questions: Product 1 Product 2 Product 3 Direct Material Cost $25,000 $30,000 $35,000 Direct Labor Cost $30,000 $40,000 $50,000 Direct Labor Hours...
-
The consumer reviews on Yelp (www.yelp.com) can be a promotional boon to any local business-provided the reviews are positive, of course. Negative reviews, fair or not, can affect a company's...
-
What is parallel construction, and why is it important?
-
How can you distinguish yourself from other candidates in a screening interview and still keep your responses short and to the point? Explain. Discuss.
-
A second-order dynamic system is modeled as \[9 \ddot{x}+6 \dot{x}+\frac{10}{9} x=14 \delta(t), \quad x(0)=0, \quad \dot{x}(0)=-\frac{1}{4}\] a. Find the response \(x(t)\) in closed form. b. Plot the...
-
Consider a first-order system with time constant \(\tau\) and zero initial condition. Find the system's unit-step response for \(\tau=\frac{1}{3}\) and \(\frac{2}{3}\), plot the two curves versus \(0...
-
a. Identify the damping type and find the free response. b. Plot the free response by using the initial command. \(\ddot{x}+3 \dot{x}+4 x=0, \quad x(0)=\frac{2}{5}, \quad \dot{x}(0)=0\)
Study smarter with the SolutionInn App