Compare commits
13 Commits
m-endo
...
26deaa412d
| Author | SHA1 | Date | |
|---|---|---|---|
| 26deaa412d | |||
| 270a29f787 | |||
| 53d0b769aa | |||
| d16b47bc60 | |||
| e8bdd3f18a | |||
| 3e40796e6e | |||
| da9fa4acd6 | |||
| ec823eeab3 | |||
| 0191dad61b | |||
| 0ea87e48f0 | |||
| 199b61f39d | |||
| aa756e3b97 | |||
| 1ced99f389 |
37
Exercises/src/Day2/Day2_5.java
Normal file
37
Exercises/src/Day2/Day2_5.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
48
Exercises/src/Day2/StringCheck.java
Normal file
48
Exercises/src/Day2/StringCheck.java
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
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();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
34
Exercises/src/day_1/StringCheck.java
Normal file
34
Exercises/src/day_1/StringCheck.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
BIN
doc/テストケース一覧_Hein.xlsx
Normal file
BIN
doc/テストケース一覧_Hein.xlsx
Normal file
Binary file not shown.
@@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="module" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
|
||||||
</classpath>
|
|
||||||
1
lesson1/.gitignore
vendored
1
lesson1/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
/bin/
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>lesson1</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
eclipse.preferences.version=1
|
|
||||||
encoding/<project>=UTF-8
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=21
|
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
|
||||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
|
||||||
org.eclipse.jdt.core.compiler.release=enabled
|
|
||||||
org.eclipse.jdt.core.compiler.source=21
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package lesson1;
|
|
||||||
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
public class StringCheck {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String[] comment = new String[4];
|
|
||||||
comment[0] = "いまなにしてる?";
|
|
||||||
comment[1] = "何も入力されていません";
|
|
||||||
comment[2] = "投稿文が長すぎます";
|
|
||||||
comment[3] = "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓";
|
|
||||||
|
|
||||||
System.out.println(comment[0]);
|
|
||||||
Scanner scanner = new Scanner(System.in);
|
|
||||||
String text = scanner.next();
|
|
||||||
String str = text.strip();
|
|
||||||
System.out.println("\n" + comment[3]);
|
|
||||||
System.out.println(str);
|
|
||||||
|
|
||||||
boolean isEmpty = str.isEmpty();
|
|
||||||
System.out.println(isEmpty);
|
|
||||||
|
|
||||||
int strLength = str.length();
|
|
||||||
System.out.println(strLength + "文字");
|
|
||||||
|
|
||||||
boolean isRange = strLength > 140;
|
|
||||||
System.out.println(isRange);
|
|
||||||
|
|
||||||
System.out.println(140 - str.length());
|
|
||||||
|
|
||||||
//一日目
|
|
||||||
|
|
||||||
for (String a : comment ) {
|
|
||||||
System.out.println(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
|
|
||||||
int strLength = str.length();
|
|
||||||
System.out.println(strLength + "文字");
|
|
||||||
|
|
||||||
boolean isRange = strLength > 140;
|
|
||||||
System.out.println(isRange);
|
|
||||||
|
|
||||||
System.out.println(140 - str.length());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user