Ad
Code
Diff
  • class Kata{
      
      public static Boolean verifySum(String nameOne, String nameTwo) {
            int sumOfNames = 0;
    
            if (nameOne == null || nameTwo == null) {
                return null;
            }
    
            for (char ch : nameOne.toCharArray()){
                sumOfNames += ch;
            }
    
            for (char ch : nameTwo.toCharArray()){
                sumOfNames -= ch;
            }
    
            return sumOfNames == 0;
        }
    }
    • class Kata{
    • public static String verifySum(String nameOne, String nameTwo) {
    • int[] sumOfNames = new int[]{0, 0};
    • public static Boolean verifySum(String nameOne, String nameTwo) {
    • int sumOfNames = 0;
    • if (nameOne == null || nameTwo == null) {
    • return "NULL";
    • return null;
    • }
    • for (int i = 0; i < nameOne.length(); i++){
    • sumOfNames[0] += nameOne.charAt(i);
    • for (char ch : nameOne.toCharArray()){
    • sumOfNames += ch;
    • }
    • for (int i = 0; i < nameTwo.length(); i++){
    • sumOfNames[1] += nameTwo.charAt(i);
    • for (char ch : nameTwo.toCharArray()){
    • sumOfNames -= ch;
    • }
    • return sumOfNames[0] == sumOfNames[1] ? "TRUE" : "FALSE";
    • return sumOfNames == 0;
    • }
    • }