2日目 段階4修正しました。
正常な場合をWhileから出すのが正解なのであれば、"↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓"のsysoutするところでエラーになってしまい解決できなかったので、レビューの際教えていただきたいです。
This commit is contained in:
42
StringCheck/src/stringCheck/StringCheck4.java
Normal file
42
StringCheck/src/stringCheck/StringCheck4.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package stringCheck;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class StringCheck4 {
|
||||
public static void main(String[] args) {
|
||||
String[] comment = new String[4];
|
||||
comment[0] = "いまなにしてる?";
|
||||
comment[1] = "何も入力されていません";
|
||||
comment[2] = "投稿文が長すぎます";
|
||||
comment[3] = "\"↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓\"";
|
||||
|
||||
|
||||
|
||||
while (true) {
|
||||
System.out.println(comment[0]);
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
String text = scanner.nextLine();
|
||||
String str = text.strip();
|
||||
|
||||
if(str.length() == 0) {
|
||||
System.out.println("何も入力されていません");
|
||||
continue;
|
||||
}else if(str.length() > 140){
|
||||
System.out.println("投稿文が長すぎます");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
System.out.println("\n" + comment[3]);
|
||||
System.out.println(str);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user