#12 Finished Fundamental Lab.

Открыто
wtsimkins хочет смерджить 3 коммит(ов) из wtsimkins/ZCW-Lab-Fundamental-Methods:master в master
wtsimkins прокомментировал 6 лет назад
Пока нет содержимого.
nhu313 прокомментировал 6 лет назад
Владелец

Predicate

For the predicate, the comparison sign returns a boolean. So you don't have to do the if statement. You can say

public Boolean isGreaterThan(int x, int y) {
   return x>y;
}

String

  • For the concat method, a shorter way to concat is this:
    public String concatenation(int firstSegment, String secondSegment){
       return firstSegment + secondSegment;
    }

You don't need to convert the integer to string. Java will do that for you.

  • For getSuffix, you can inline it into one statement.
    public String getSuffix(String input){
        return input.substring(input.length() - 3);
    }

If you don't inline it, be more descriptive with your variable name.

    public String getSuffix(String input){
        int strLength = input.length();
        int suffixStartIndex = strLength - 3;
        return input.substring(suffixStartIndex);
    }
  • For compareTwoStrings, getFirstWord, getSecondWord, if you don't need to use the variable, you don't have to create one. So instead of
public Boolean compareTwoStrings(String inputValue, String comparableValue){
        Boolean a = inputValue.equals(comparableValue);
        return a;
    }

You can write it as

public Boolean compareTwoStrings(String inputValue, String comparableValue){
       return inputValue.equals(comparableValue);
    }
  • For getMiddleCharacter this should not pass all the test.

Please clean up the string and predicate lab and send me a message on slack when you're done.

### Predicate For the predicate, the comparison sign returns a boolean. So you don't have to do the if statement. You can say ``` public Boolean isGreaterThan(int x, int y) { return x>y; } ``` ### String - For the concat method, a shorter way to concat is this: ``` public String concatenation(int firstSegment, String secondSegment){ return firstSegment + secondSegment; } ``` You don't need to convert the integer to string. Java will do that for you. - For `getSuffix`, you can inline it into one statement. ``` public String getSuffix(String input){ return input.substring(input.length() - 3); } ``` If you don't inline it, be more descriptive with your variable name. ``` public String getSuffix(String input){ int strLength = input.length(); int suffixStartIndex = strLength - 3; return input.substring(suffixStartIndex); } ``` - For `compareTwoStrings`, `getFirstWord`, `getSecondWord`, if you don't need to use the variable, you don't have to create one. So instead of ``` public Boolean compareTwoStrings(String inputValue, String comparableValue){ Boolean a = inputValue.equals(comparableValue); return a; } ``` You can write it as ``` public Boolean compareTwoStrings(String inputValue, String comparableValue){ return inputValue.equals(comparableValue); } ``` - For `getMiddleCharacter` this should not pass all the test. Please clean up the string and predicate lab and send me a message on slack when you're done.
Этот Pull Request может быть объединён автоматически.
Войдите, чтобы присоединиться к обсуждению.
Нет меток
Нет этапа
Нет ответственного
2 участников
Загрузка...
Отмена
Сохранить
Пока нет содержимого.