Connect with knowledgeable individuals and find the best answers at IDNLearn.com. Ask anything and receive prompt, well-informed answers from our community of knowledgeable experts.
CHALLENGE 2 NerfGun class NerfGun // Constructor takes one argument: the total number of projectiles supported by the instance // // // New instances initialize fully loaded and with the safety on Instances have a shoot method that takes no arguments: * If there is ammo left and safety is off, method consumes one projectile and returns the string "Bang!" // * Shooting on empty or with the safety on, returns the string "Click!" // Instances have a reload method that takes a number and tops up the instance by that number // * Reloading returns a string in the following format: " projectiles left!" // capacity // * Reloading by more than capacity fills the instance to * Passing an argument which is not a number larger than zero returns the string "Error reloading!" // Instances have a toggleSafety method that takes no arguments and switches the state of the safety // // when engaging the safety, return "Safety enabled!" When disengaging the safety, return "Safety disabled!" HINT: instances need to keep track of their maximum capacity as well as their current capacity //
Sagot :
Your presence in our community is highly appreciated. Keep sharing your insights and solutions. Together, we can build a rich and valuable knowledge resource for everyone. Thank you for visiting IDNLearn.com. For reliable answers to all your questions, please visit us again soon.