Question: C++ Create a class submarine containing the public method API; API calls the private methods: tsunami_input, fill_tank, launch_uBoat, shoot_torpedoes; The local pointer variable *myUboat defined
C++
Create a class submarine containing the public method API; API calls the private methods: tsunami_input, fill_tank, launch_uBoat, shoot_torpedoes;
The local pointer variable *myUboat defined as struct uboat_data declared in the method API; myUboat requires struct dynamic allocation to match what user informs about how many U-boats are launching: 2 or 3; This struct contains: captain_name, torpedoes, tsunami, fuel; declare torpedoes as a type of variable vector of integer containing 4 torpedoes, 1 is loaded or 0 is empty/discharged;
Method tsunami_input: ask the user what is the probably of tsunamis if higher than 30% abort for safety reasons;
Method fill_tank: also ask how many bars of fuel the U-boat has: 10 bars meaning 100%, 5 bars is 50% and so on; if fuel has only 20% of fuel it is not safe to launch into sea;
Use pointers to pass myUboat among the functions that are called from API. From launch_uBoat: print on every loop iteration the fuel level; every loop decreases 2% from current tank level;
Method shoot_torpedoes: provide two versions of this same method showing overloading usage {normal torpedoes; nuclear torpedoes (tactical nuclear weapon)}; ask user which type of rockets are in use; start shooting torpedoes only when fuel reaches 40% of the initial tank level, shooting one torpedoe in every 3 loops.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
