2日目 段階4 小澤
StringCheckが段階3までで使用していたクラスで、StringCheckRefが段階4で書き直したものです。
This commit is contained in:
@@ -10,9 +10,7 @@ public class StringCheck {
|
|||||||
comment[2] = "投稿文が長すぎます";
|
comment[2] = "投稿文が長すぎます";
|
||||||
comment[3] = "\"↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓\"";
|
comment[3] = "\"↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓\"";
|
||||||
|
|
||||||
// for (String testComm : comment) {
|
|
||||||
// System.out.println(testComm);
|
|
||||||
// }
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
System.out.println(comment[0]);
|
System.out.println(comment[0]);
|
||||||
@@ -20,12 +18,9 @@ public class StringCheck {
|
|||||||
String text = scanner.nextLine();
|
String text = scanner.nextLine();
|
||||||
String str = text.strip();
|
String str = text.strip();
|
||||||
|
|
||||||
// System.out.println(str.length() == 0);
|
|
||||||
// System.out.println(str.length() > 140);
|
|
||||||
//
|
|
||||||
// System.out.println(140 - str.length());
|
|
||||||
|
|
||||||
if(str.length() < 1) {
|
|
||||||
|
if(str.length() == 0) {
|
||||||
System.out.println("何も入力されていません");
|
System.out.println("何も入力されていません");
|
||||||
continue;
|
continue;
|
||||||
}else if(str.length() > 140){
|
}else if(str.length() > 140){
|
||||||
|
|||||||
39
StringCheck/src/stringCheck/StringCheckRef.java
Normal file
39
StringCheck/src/stringCheck/StringCheckRef.java
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package stringCheck;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class StringCheckRef {
|
||||||
|
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((0<str.length()) && (str.length()<=140)){
|
||||||
|
System.out.println("\n" + comment[3]);
|
||||||
|
System.out.println(str);
|
||||||
|
break;
|
||||||
|
}else if(str.length() == 0) {
|
||||||
|
System.out.println("何も入力されていません");
|
||||||
|
continue;
|
||||||
|
}else {
|
||||||
|
System.out.println("投稿文が長すぎます");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user