段階2終わりました
This commit is contained in:
@@ -15,14 +15,12 @@ public class StringCheck {
|
|||||||
//標準入力から1行分の文字列を読み込む
|
//標準入力から1行分の文字列を読み込む
|
||||||
Scanner scan = new Scanner(System.in);
|
Scanner scan = new Scanner(System.in);
|
||||||
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
System.out.println(classNames[0]);
|
System.out.println(classNames[0]);
|
||||||
|
|
||||||
String str = scan.nextLine();
|
String str = scan.nextLine();
|
||||||
|
|
||||||
|
|
||||||
// 文字列の長さを取得
|
// 文字列の長さを取得
|
||||||
int length = str.length();
|
int length = str.length();
|
||||||
|
|
||||||
@@ -35,6 +33,8 @@ public class StringCheck {
|
|||||||
// 残り入力可能文字数
|
// 残り入力可能文字数
|
||||||
int a = (140 - length);
|
int a = (140 - length);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println(classNames[3]);
|
System.out.println(classNames[3]);
|
||||||
|
|
||||||
@@ -42,16 +42,19 @@ public class StringCheck {
|
|||||||
System.out.println(str.strip());
|
System.out.println(str.strip());
|
||||||
|
|
||||||
|
|
||||||
}
|
// if文による検証ロジック
|
||||||
|
if (isEmpty) {
|
||||||
|
System.out.println("何も入力されていません");
|
||||||
|
continue;
|
||||||
// for-each練習
|
} else if (isOverLimit) {
|
||||||
// for (String name : classNames) {
|
System.out.println("投稿文が長すぎます");
|
||||||
// System.out.println(name);
|
continue;
|
||||||
// }
|
} else {
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user