3日目
This commit is contained in:
68
StringCheck.java
Normal file
68
StringCheck.java
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
|
||||||
|
public class StringCheck {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
|
|
||||||
|
String[] name = {"いまなにしてる?", "何も入力されていません", "投稿文が長すぎます","↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓"};
|
||||||
|
|
||||||
|
String str;
|
||||||
|
|
||||||
|
str = (" gagaga" );
|
||||||
|
String stripped = str.strip();
|
||||||
|
//テスト
|
||||||
|
/*for (String stra : name ) {
|
||||||
|
System.out.println(stra);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
|
||||||
|
System.out.println(name[0]);
|
||||||
|
|
||||||
|
if (stripped.length() == 0) {
|
||||||
|
|
||||||
|
System.out.println(name[1]);
|
||||||
|
|
||||||
|
} else if (stripped.length() > 140) {
|
||||||
|
|
||||||
|
System.out.println(name[2]);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
System.out.println(stripped);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}}
|
||||||
|
System.out.println(" ");
|
||||||
|
|
||||||
|
System.out.println(name[3]);
|
||||||
|
|
||||||
|
System.out.println(stripped);
|
||||||
|
|
||||||
|
System.out.println(140 - stripped.length());
|
||||||
|
|
||||||
|
//0を超える文字数
|
||||||
|
System.out.println(0 <= stripped.length());
|
||||||
|
|
||||||
|
//140文字未満
|
||||||
|
System.out.println(stripped.length() <= 140);
|
||||||
|
}
|
||||||
|
|
||||||
|
//空白除去
|
||||||
|
public static String inputStrng(String str) {
|
||||||
|
String stripped;
|
||||||
|
return stripped = str.strip();
|
||||||
|
}
|
||||||
|
|
||||||
|
//空文字判定
|
||||||
|
//public static String isEmptyInput() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//文字数超過判定
|
||||||
|
//public static String isTooLongInput() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
68
StringCheck20261009_平山.java
Normal file
68
StringCheck20261009_平山.java
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
|
||||||
|
public class StringCheck {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
|
|
||||||
|
String[] name = {"いまなにしてる?", "何も入力されていません", "投稿文が長すぎます","↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓"};
|
||||||
|
|
||||||
|
String str;
|
||||||
|
|
||||||
|
str = (" gagaga" );
|
||||||
|
String stripped = str.strip();
|
||||||
|
//テスト
|
||||||
|
/*for (String stra : name ) {
|
||||||
|
System.out.println(stra);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
|
||||||
|
System.out.println(name[0]);
|
||||||
|
|
||||||
|
if (stripped.length() == 0) {
|
||||||
|
|
||||||
|
System.out.println(name[1]);
|
||||||
|
|
||||||
|
} else if (stripped.length() > 140) {
|
||||||
|
|
||||||
|
System.out.println(name[2]);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
System.out.println(stripped);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}}
|
||||||
|
System.out.println(" ");
|
||||||
|
|
||||||
|
System.out.println(name[3]);
|
||||||
|
|
||||||
|
System.out.println(stripped);
|
||||||
|
|
||||||
|
System.out.println(140 - stripped.length());
|
||||||
|
|
||||||
|
//0を超える文字数
|
||||||
|
System.out.println(0 <= stripped.length());
|
||||||
|
|
||||||
|
//140文字未満
|
||||||
|
System.out.println(stripped.length() <= 140);
|
||||||
|
}
|
||||||
|
|
||||||
|
//空白除去
|
||||||
|
public static String inputStrng(String str) {
|
||||||
|
String stripped;
|
||||||
|
return stripped = str.strip();
|
||||||
|
}
|
||||||
|
|
||||||
|
//空文字判定
|
||||||
|
//public static String isEmptyInput() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//文字数超過判定
|
||||||
|
//public static String isTooLongInput() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user