Day 2 Stept 2
This commit is contained in:
@@ -9,17 +9,40 @@ public class StringCheck {
|
||||
|
||||
Scanner scan = new Scanner(System.in);
|
||||
String str = "";
|
||||
//int maxLength = 140;
|
||||
|
||||
// 段階1: 無限ループ化
|
||||
while (true) {
|
||||
System.out.println(messages[0]);
|
||||
str = scan.nextLine().trim();
|
||||
|
||||
System.out.println("あなたの入力は: [" + str + "]");
|
||||
//System.out.println("あなたの入力は: [" + str + "]");
|
||||
|
||||
|
||||
//2段階のif
|
||||
boolean isEmpty = str.isEmpty();
|
||||
boolean isTooLong = str.length() > 140;
|
||||
if(isEmpty) {
|
||||
System.out.println(messages[1]);
|
||||
continue;
|
||||
}
|
||||
// ၂။ စာလုံးရေ ပိုလွန်မှု စစ်ဆေးခြင်း (Length check)
|
||||
|
||||
if (isTooLong) {
|
||||
System.out.println(messages[2]);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println(messages[3]);
|
||||
System.out.println(str);
|
||||
|
||||
scan.close();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user