Problem

Complete the given apex method to mask credit card numbers. All numbers except the last four digits should be replaced with 'X'.


Complete the provided apex method to fulfill these requirements.

Instructions:


1. Accept a string parameter as input.


2. Replace the first three blocks of numbers in the credit card with 'X'.


3. Retain the last four digits of the numbers as they are.


4. Return the masked credit card number from the apex method.



Example:


String cardNumber = '4320-2345-7185-5645';
String maskedNumber = cardManager.maskCardNumbers(cardNumber);
// maskedNumber will be XXXX-XXXX-XXXX-5645


Note: String is a primitive data type in apex. Apex provides a set of built in functions to operate on strings. See the official documentation for apex string methods and utilize them to solve this scenario.