1. Java / Говнокод #23703

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    решение:
    class Twofer {
        String twofer(String name) {
            if (name.equalsIgnoreCase("Alice")){
                return "One for Alice, one for me.";
            } else if (name.equalsIgnoreCase("Bob")) {
                return "One for Bob, one for me.";
            } else {
                return "One for you, one for me.";
            }
        }
    }
    
    
    чтобы эти тесты проходили

    задачка:
    # Two Fer

    `Two-fer` or `2-fer` is short for two for one. One for you and one for me.

    ```text
    "One for X, one for me."
    ```

    When X is a name or "you".

    If the given name is "Alice", the result should be "One for Alice, one for me."
    If no name is given, the result should be "One for you, one for me."


    чувак решил не заморачиваться...

    Запостил: Lure Of Chaos, 03 Февраля 2018

    Комментарии (17) RSS

    • тесты
      public class TwoferTest {
      
          private Twofer twofer;
      
          @Before
          public void setup() {
              twofer = new Twofer();
          }
      
          @Test
          public void noNameGiven() {
              String input = null;
              String expected = "One for you, one for me.";
      
              assertEquals(expected, twofer.twofer(input));
          }
      
          @Ignore("Remove to run test")
          @Test
          public void aNameGiven() {
              String input = "Alice";
              String expected = "One for Alice, one for me.";
      
              assertEquals(expected, twofer.twofer(input));
          }
      
          @Ignore("Remove to run test")
          @Test
          public void anotherNameGiven() {
              String input = "Bob";
              String expected = "One for Bob, one for me.";
      
              assertEquals(expected, twofer.twofer(input));
          }
      }
      Ответить
    • Topcoder?
      Ответить
    • if (name.equalsIgnoreCase("d'Artagnan")) {
                  return "One for all, all for one!";
      Ответить
    • Давайте саммонить олдфагов
      Ответить
    • Случайно наткнулся на тебя:
      https://habr.com/users/lure_of_chaos/
      Ответить

    Добавить комментарий