回答編集履歴

6

ソース修正

2019/10/10 01:29

投稿

cateye
cateye

スコア6851

test CHANGED
@@ -86,7 +86,7 @@
86
86
 
87
87
  } else {
88
88
 
89
- do {//while(true){
89
+ while(!PassOK){
90
90
 
91
91
 
92
92
 
@@ -184,7 +184,7 @@
184
184
 
185
185
  PassOK = true;
186
186
 
187
- } while (!PassOK);
187
+ }
188
188
 
189
189
  }
190
190
 

5

ソース追記

2019/10/10 01:29

投稿

cateye
cateye

スコア6851

test CHANGED
@@ -61,3 +61,135 @@
61
61
  Process finished with exit code 0
62
62
 
63
63
  ```
64
+
65
+ 「現状」
66
+
67
+ ```java
68
+
69
+ public static void main(String[] args) {
70
+
71
+ Scanner input = new Scanner(System.in);
72
+
73
+ boolean PassOK = false;
74
+
75
+ while (!PassOK) {
76
+
77
+ System.out.print("input password? ");
78
+
79
+ String pass = input.nextLine();
80
+
81
+ System.out.println("password:" + pass);
82
+
83
+ if (pass.equals("abc")) {
84
+
85
+ break;
86
+
87
+ } else {
88
+
89
+ do {//while(true){
90
+
91
+
92
+
93
+ int i;
94
+
95
+
96
+
97
+ if (pass.length() < 8) {
98
+
99
+ System.out.println(" Your password must be at least 8 characters.");
100
+
101
+ break;
102
+
103
+ }
104
+
105
+
106
+
107
+ for (i = 0; i < pass.length(); i++) {
108
+
109
+ if (Character.isUpperCase(pass.charAt(i))) {
110
+
111
+ break;
112
+
113
+ }
114
+
115
+ }
116
+
117
+ if (i == pass.length()) {
118
+
119
+ System.out.println(" Your password must contain at least one uppercase letter.");
120
+
121
+ break;
122
+
123
+ }
124
+
125
+
126
+
127
+ for (i = 0; i < pass.length(); i++) {
128
+
129
+ if (Character.isLowerCase(pass.charAt(i))) {
130
+
131
+ break;
132
+
133
+ }
134
+
135
+ }
136
+
137
+ if (i == pass.length()) {
138
+
139
+ System.out.println(" Your password must contain at least one lowercase letter.");
140
+
141
+ break;
142
+
143
+ }
144
+
145
+
146
+
147
+ for (i = 0; i < pass.length(); i++) {
148
+
149
+ if (Character.isDigit(pass.charAt(i))) {
150
+
151
+ break;
152
+
153
+ }
154
+
155
+ }
156
+
157
+ if (i == pass.length()) {
158
+
159
+ System.out.println(" Your password must contain a numeber.");
160
+
161
+ break;
162
+
163
+ }
164
+
165
+
166
+
167
+ if (pass.contains("password")) {
168
+
169
+ System.out.println(" Your password cannot contain word 'password.'");
170
+
171
+ break;
172
+
173
+ }
174
+
175
+
176
+
177
+ if (pass.contains(" ")) {
178
+
179
+ System.out.println(" You password can only contain aplha numeric characters.");
180
+
181
+ break;
182
+
183
+ }
184
+
185
+ PassOK = true;
186
+
187
+ } while (!PassOK);
188
+
189
+ }
190
+
191
+ }
192
+
193
+ }
194
+
195
+ ```

4

ソース修正

2019/10/10 00:13

投稿

cateye
cateye

スコア6851

test CHANGED
@@ -28,33 +28,33 @@
28
28
 
29
29
  Your password must be at least 8 characters.
30
30
 
31
+ input password? abcd
31
32
 
32
-
33
- password:
33
+ password:abcd
34
34
 
35
35
  Your password must be at least 8 characters.
36
36
 
37
- www
37
+ input password? ABCDEFGHI
38
38
 
39
+ password:ABCDEFGHI
40
+
41
+ Your password must contain at least one lowercase letter.
42
+
43
+ input password? abcdefg
44
+
39
- password:www
45
+ password:abcdefg
40
46
 
41
47
  Your password must be at least 8 characters.
42
48
 
43
- wwwwwwwww
49
+ input password? 12345678
44
50
 
45
- password:wwwwwwwww
51
+ password:12345678
46
52
 
47
53
  Your password must contain at least one uppercase letter.
48
54
 
49
- anc
55
+ input password? abc123ABC
50
56
 
51
- password:anc
52
-
53
- Your password must be at least 8 characters.
54
-
55
- abc
56
-
57
- password:abc
57
+ password:abc123ABC
58
58
 
59
59
 
60
60
 

3

ソース修正

2019/10/09 23:47

投稿

cateye
cateye

スコア6851

test CHANGED
@@ -20,9 +20,39 @@
20
20
 
21
21
  の処理は、一番外側のwhile()の内側にないとおかしいのでは?
22
22
 
23
- ```java
23
+ ```text
24
24
 
25
- input password? abc
25
+ input password? 123
26
+
27
+ password:123
28
+
29
+ Your password must be at least 8 characters.
30
+
31
+
32
+
33
+ password:
34
+
35
+ Your password must be at least 8 characters.
36
+
37
+ www
38
+
39
+ password:www
40
+
41
+ Your password must be at least 8 characters.
42
+
43
+ wwwwwwwww
44
+
45
+ password:wwwwwwwww
46
+
47
+ Your password must contain at least one uppercase letter.
48
+
49
+ anc
50
+
51
+ password:anc
52
+
53
+ Your password must be at least 8 characters.
54
+
55
+ abc
26
56
 
27
57
  password:abc
28
58
 

2

加筆

2019/10/09 22:58

投稿

cateye
cateye

スコア6851

test CHANGED
@@ -19,3 +19,15 @@
19
19
  System.out.println("password:" + pass);
20
20
 
21
21
  の処理は、一番外側のwhile()の内側にないとおかしいのでは?
22
+
23
+ ```java
24
+
25
+ input password? abc
26
+
27
+ password:abc
28
+
29
+
30
+
31
+ Process finished with exit code 0
32
+
33
+ ```

1

追記

2019/10/09 22:49

投稿

cateye
cateye

スコア6851

test CHANGED
@@ -9,3 +9,13 @@
9
9
  →[【Java入門】文字列(String)を比較する方法(「==」と「equals」)
10
10
 
11
11
  ](https://www.sejuku.net/blog/14621)
12
+
13
+
14
+
15
+ 「追記」
16
+
17
+ String pass = input.nextLine();
18
+
19
+ System.out.println("password:" + pass);
20
+
21
+ の処理は、一番外側のwhile()の内側にないとおかしいのでは?