Write a method for Pirate called payBounty. This method does…
Write a method for Pirate called payBounty. This method doesn’t take any parameters or return a value. The pirate will pay as much of their bounty as possible. If the amount of gold they have meets or exceeds their bounty, it will deduct the bounty from the gold and set the bounty to 0. Otherwise, the pirate will pay as much of their bounty as possible by deducting the gold from their bounty and setting their gold to 0. Tip: This is equivalent to deducting the minimum of bounty and gold from the two instance variables.