Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

土屋の解答 #16

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

土屋の解答 #16

wants to merge 23 commits into from

Conversation

ftsuchiya
Copy link
Collaborator

No description provided.

@ftsuchiya ftsuchiya changed the title 土屋_Practice001の解答 土屋の解答 Apr 10, 2019
Copy link
Collaborator

@m4K1T m4K1T left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

005までレビューいれました

return true;
} else {
return false;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここも三項演算子で書けます!

if(n >= 0) {
return n % 2 == 0 ? "正の偶数" : "正の奇数";
}else{
return n % 2 == 0 ? "負の偶数" : "負の奇数";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なかなかすっきりしていて良きなロジックですね!

return "合格";
} else {
return "不合格";

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto 三項演算子

return "可";
} else {
return "不可";
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ifの条件は整理されてていい感じです!
「ガード節」というキーワードで調べてみてください!
https://qiita.com/kouyan/items/7b8b456b626447a1e24e

}
if (n == 1) {
return false;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ガードできてる!いいね!

if (n % i == 0) {

soinsu += " " + i;
n = n / i;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

忘れた頃に /=


while (n > 0) {
nishinsu = (n % 2) + nishinsu;
n = n / 2;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto /=

for (int i = 0; i < list.size(); i++) {
returnArray[i] = list.get(i);
}
return returnArray;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good


}

// 並べ替えられた配列を返す
public static int[] sort(int[] n) {
Arrays.sort(n);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great

if (str.contains("ge")) {
return true;
}
return false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

もしかしてif文すらいらないかもしれない

if (n % 5 == 0 || s.contains("5")) {
return "buzz";
}
return"";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

せっかくPractice016,017で作ったメソッド、使いましょう。

}

public static boolean isMailAddress(String s) {

return false;
return s.matches("^[\\w.!#$%&'*+/=?^_`{|}~-]+@[\\w.!#$%&'*+/=?^_`{|}~-]+(\\.com$|\\.co.jp|\\.ne.jp$)");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これだと hoge@hoge.neajp のときにtrueになっちゃいませんか?
. の扱いに気をつけましょう。

@Kotanin0 Kotanin0 added the 要リファクタ ⛔ リファクタリングをしてください label Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
小谷レビュー済:cyclone: 要リファクタ ⛔ リファクタリングをしてください
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants