Upgrade to Pro — share decks privately, control downloads, hide ads and more …

はじめようきれいなコード

 はじめようきれいなコード

きりみん

June 01, 2018
Tweet

More Decks by きりみん

Other Decks in Programming

Transcript

  1. ྫ୊ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean flag; if (list.isEmpty()) { flag = false; } else { if (list.get(0).equals("a")) { if (list.size() > 2) { if (list.get(1).equals("b")) { if (list.size() > 3) { if (list.get(2).equals("c")) { flag = true; } else { flag = false; } } else { flag = false; } } else { flag = false; } } else { flag = false; } } flag = false; } if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  2. ྫ୊ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean flag; if (list.isEmpty()) { flag = false; } else { if (list.get(0).equals("a")) { if (list.size() > 2) { if (list.get(1).equals("b")) { if (list.size() > 3) { if (list.get(2).equals("c")) { flag = true; } else { flag = false; } } else { flag = false; } } else { flag = false; } } else { flag = false; } } flag = false; } if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  3. FMTFʹॲཧ͕ͨ͘͞Μ͋Δ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean flag; if (list.isEmpty()) { flag = false; } else { if (list.get(0).equals("a")) { if (list.size() > 2) { if (list.get(1).equals("b")) { if (list.size() > 3) { if (list.get(2).equals("c")) { flag = true; } else { flag = false; } } else { flag = false; } } else { flag = false; } } else { flag = false; } } flag = false; } if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  4. ൑ఆΛٯʹ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean flag; if (!list.isEmpty()) { if (list.get(0).equals("a")) { if (list.size() > 2) { if (list.get(1).equals("b")) { if (list.size() > 3) { if (list.get(2).equals("c")) { flag = true; } else { flag = false; } } else { flag = false; } } else { flag = false; } } else { flag = false; } } } else { flag = false; } if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  5. ಉ͡ྲྀΕͳͷʹผʑʹ൑ఆͯ͠Δ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean flag; if (!list.isEmpty()) { if (list.get(0).equals("a")) { if (list.size() > 2) { if (list.get(1).equals("b")) { if (list.size() > 3) { if (list.get(2).equals("c")) { flag = true; } else { flag = false; } } else { flag = false; } } else { flag = false; } } else { flag = false; } } } else { flag = false; } if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  6. ൑ఆΛͰ·ͱΊΔ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean flag; if (!list.isEmpty()) { if (list.get(0).equals("a")) { if (list.size() > 2 && list.get(1).equals("b")) { if (list.size() > 3 && list.get(2).equals("c")) { flag = true; } else { flag = false; } } else { flag = false; } } else { flag = false; } } else { flag = false; } if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  7. ࠷ॳͷํ΋ಉ͡൑ఆͰΑͦ͞͏ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean flag; if (!list.isEmpty()) { if (list.get(0).equals("a")) { if (list.size() > 2 && list.get(1).equals("b")) { if (list.size() > 3 && list.get(2).equals("c")) { flag = true; } else { flag = false; } } else { flag = false; } } else { flag = false; } } else { flag = false; } if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  8. ̏ͭͷ൑ఆʹ̏ͭͷJGจ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean flag; if (!list.isEmpty() && list.get(0).equals("a")) { if (list.size() > 2 && list.get(1).equals("b")) { if (list.size() > 3 && list.get(2).equals("c")) { flag = true; } else { flag = false; } } else { flag = false; } } else { flag = false; } if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  9. Ͱ΋͜ͷ൑ఆ͢͜͠෼͔Γʹ͍͘ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean flag; if (!list.isEmpty() && list.get(0).equals("a")) { if (list.size() > 2 && list.get(1).equals("b")) { if (list.size() > 3 && list.get(2).equals("c")) { flag = true; } else { flag = false; } } else { flag = false; } } else { flag = false; } if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  10. ม਺ʹ੾Γग़໊ͯ͠લΛ͚ͭͨ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean flag; boolean isFirstA = !list.isEmpty() && list.get(0).equals("a") boolean isSecondB = !list.isEmpty() && list.get(1).equals("b") boolean isThirdC = !list.isEmpty() && list.get(2).equals("c") if (isFirstA) { if (isSecondB) { if (isThirdC) { flag = true; } else { flag = false; } } else { flag = false; } } else { flag = false; } if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  11. ͦ΋ͦ΋࣮͸͜ͷJGจ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean flag; boolean isFirstA = !list.isEmpty() && list.get(0).equals("a") boolean isSecondB = !list.isEmpty() && list.get(1).equals("b") boolean isThirdC = !list.isEmpty() && list.get(2).equals("c") if (isFirstA) { if (isSecondB) { if (isThirdC) { flag = true; } else { flag = false; } } else { flag = false; } } else { flag = false; } if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  12. ͍Βͳ͍ΜͩΑͶ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean isFirstA = !list.isEmpty() && list.get(0).equals("a") boolean isSecondB = !list.isEmpty() && list.get(1).equals("b") boolean isThirdC = !list.isEmpty() && list.get(2).equals("c") boolean flag = isFirstA && isSecondB && isThirdC; if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  13. CPPMFBOΛͰ൑ఆͯ͠Δ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean isFirstA = !list.isEmpty() && list.get(0).equals("a") boolean isSecondB = !list.isEmpty() && list.get(1).equals("b") boolean isThirdC = !list.isEmpty() && list.get(2).equals("c") boolean flag = isFirstA && isSecondB && isThirdC; if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  14. ৑௕ͳͷͰ GMBH Ͱ͍͍ public static void main(String[] args) { List<String>

    list = new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean isFirstA = !list.isEmpty() && list.get(0).equals("a") boolean isSecondB = !list.isEmpty() && list.get(1).equals("b") boolean isThirdC = !list.isEmpty() && list.get(2).equals("c") boolean flag = isFirstA && isSecondB && isThirdC; if (flag) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  15. ͦ΋ͦ΋͜ͷGMBH໊ͬͯલ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean isFirstA = !list.isEmpty() && list.get(0).equals("a") boolean isSecondB = !list.isEmpty() && list.get(1).equals("b") boolean isThirdC = !list.isEmpty() && list.get(2).equals("c") boolean flag = isFirstA && isSecondB && isThirdC; if (flag) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  16. ҙຯͷΘ͔Δ໊લΛ͚ͭΑ͏ public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean isFirstA = !list.isEmpty() && list.get(0).equals("a") boolean isSecondB = !list.isEmpty() && list.get(1).equals("b") boolean isThirdC = !list.isEmpty() && list.get(2).equals("c") boolean isABC = isFirstA && isSecondB && isThirdC; if (isABC) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  17. CFGPSF public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean flag; if (list.isEmpty()) { flag = false; } else { if (list.get(0).equals("a")) { if (list.size() > 2) { if (list.get(1).equals("b")) { if (list.size() > 3) { if (list.get(2).equals("c")) { flag = true; } else { flag = false; } } else { flag = false; } } else { flag = false; } } else { flag = false; } } flag = false; } if (flag == true) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }
  18. BGUFS public static void main(String[] args) { List<String> list =

    new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); boolean isFirstA = !list.isEmpty() && list.get(0).equals("a") boolean isSecondB = !list.isEmpty() && list.get(1).equals("b") boolean isThirdC = !list.isEmpty() && list.get(2).equals("c") boolean isABC = isFirstA && isSecondB && isThirdC; if (isABC) { System.out.println("Success!!!"); } else { System.out.println("Failed!!!"); } }