7 Commits

Author SHA1 Message Date
m-shimizu
1d393ee52e Merge branch 'main' of https://gitea.it-college.co.jp/2026_0910_AI_5G_Java_MUN/java-cui-string-checker into m-shimizu 2026-09-10 14:09:42 +09:00
m-shimizu
279229e07d day2 段階2 2026-09-09 15:39:23 +09:00
m-shimizu
2d4f4b65de day2 段階1再提出 2026-09-09 14:53:53 +09:00
m-shimizu
b77581e872 day2 段階1再提出 2026-09-09 14:22:04 +09:00
m-shimizu
6feba3dae1 day2 段階1 2026-09-09 13:44:03 +09:00
m-shimizu
8741d56ee4 Merge branch 'main' of https://gitea.it-college.co.jp/2026_0910_AI_5G_Java_MUN/java-cui-string-checker into m-shimizu 2026-09-09 11:03:05 +09:00
m-shimizu
36f2164cb7 StringCheck 2026-09-09 10:07:40 +09:00
6 changed files with 70 additions and 120 deletions

1
.gitignore vendored
View File

@@ -24,4 +24,3 @@
hs_err_pid*
replay_pid*
/.metadata/

View File

@@ -1,37 +0,0 @@
package Day2;
import java.util.Scanner;
public class Day2_5 {
public static void main(String[] args) {
String[] messages = { "いまなにしてる", "何も入力されていません", "投稿文が長すぎます", "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓" };
Scanner scan = new Scanner(System.in);
String str = "";
int maxLength = 140;
while (true) {
System.out.println(messages[0]);
str = scan.nextLine().replace(" ", "").replace(" ", "");
// 三項演算子 error message in shot the statement but this way is error race hight ( so just the study no using)
String errorMessage = str.isEmpty() ? messages[1]
: str.length() > maxLength ? messages[2] : null;
//null is need the end for root when check the statement that is reprecent for nothig any statement;
if (errorMessage != null) {
System.out.println(errorMessage);
continue;
}
break;
}
System.out.println();
System.out.println(messages[3]);
System.out.println(str);
scan.close();
}
}

View File

@@ -1,48 +0,0 @@
package Day2;
import java.util.Scanner;
public class StringCheck {
public static void main(String[] args) {
String[] messages = { "いまなにしてる", "何も入力されていません", "投稿文が長すぎます", "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓" };
Scanner scan = new Scanner(System.in);
String str = "";
//int maxLength = 140;
// 段階1: 無限ループ化
while (true) {
System.out.println(messages[0]);
str = scan.nextLine();
//str = scan.nextLine().trim();
str = str.replaceAll("[\\s ]", "");
//String str1 = str.replaceAll("[  ]", "");
//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) 140 under
if (isTooLong) {
System.out.println(messages[2]);
continue;
}
break;
}
System.out.println();
System.out.println(messages[3]);
System.out.println(str);
scan.close();
}
}

View File

@@ -1,34 +0,0 @@
package day_1;
import java.util.Scanner;
public class StringCheck {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
String[] messages = { "いまなにしてる", "何も入力されていません", "投稿文が長すぎます", "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓" };
Scanner scan = new Scanner(System.in);
System.out.println(messages[0]);
// 1 မျက်နှာစာ ဖတ်ရှုပြီး ရှေ့နောက် Space များကို ဖြတ်တောက်ခြင်း
String str = scan.nextLine().trim();
// အလုပ်လုပ်ပုံ စစ်ဆေးရန်အတွက် str ၏ ပါဝင်မှုကို ပြသခြင်း
System.out.println("入力値: [" + str + "]");
//問題3
boolean isEmpty = (str.length() == 0); // empty ckeck空文字判定:str の文字数が 0 かどうか
boolean isTooLong = (str.length() > 140); // limit spelling str の文字数が 140 を超えるかどうか
int remainingLength = 140 - str.length(); //残り入力可能文字数(140 - 文字数)
//空行を1行表示する (fill the enter)
System.out.println();
// take out arrage string number 2
System.out.println(messages[3]);
// print input string
System.out.println(str);
}
}

View File

@@ -0,0 +1,70 @@
import java.util.Scanner;
public class StringCheck_shimizu {
public static void main(String[] args) {
//画面に表示するメッセージ
String[] messages = {
"いまなにしてる?",
"何も入力されていません",
"投稿文が長すぎます",
"↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓"
};
// //段階1
// for (String message : messages) {
// System.out.println(message);
// }
Scanner scanner = new Scanner(System.in);
String Str = "";
while (true) {
//"いまなにしてる?"
System.out.println(messages[0]);
//入力された文字を取得
Str = scanner.nextLine().strip();
//"何も入力されていません"
boolean isEnpty = Str.length() == 0;
//System.out.println(isEnpty);
//"投稿文が長すぎます"
boolean ismojisu = Str.length() > 140;
//System.out.println(ismojisu);
int nokori = 140 - Str.length();
//System.out.println(nokori);
if (isEnpty) {
System.out.println(messages[1]);
continue;
}
if (ismojisu) {
System.out.println(messages[2]);
continue;
}
break;
}
//空行
System.out.println();
//↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓
System.out.println(messages[3]);
System.out.println(Str);
}
}