Skip to content

Instantly share code, notes, and snippets.

@corningsun
Created December 30, 2020 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corningsun/1afdd69da58d3ed7888ce022be76d4da to your computer and use it in GitHub Desktop.
Save corningsun/1afdd69da58d3ed7888ce022be76d4da to your computer and use it in GitHub Desktop.
v2ex-Reply39
package com.corning.v2;
public class Reply39 {
public static void main(String[] args) throws Exception {
String[] wA = new String[]{"0", "0", "0", "0", "0", "0", "0"};
new Reply39().hello("0", wA[0], wA[1], wA[2], wA[3], wA[4], wA[5], wA[6]);
// hello
new Reply39().hello("3", wA[0], wA[1], wA[2], wA[3], wA[4], wA[5], wA[6]);
// Exception in thread "main" java.lang.Exception: 设置项目参数非法!
}
public void hello(String open, String w1, String w2, String w3, String w4, String w5, String w6, String w7) throws Exception {
if (!isZeroOrOne(open)
&& isZeroOrOne(w1)
&& isZeroOrOne(w2)
&& isZeroOrOne(w3)
&& isZeroOrOne(w4)
&& isZeroOrOne(w5)
&& isZeroOrOne(w6)
&& isZeroOrOne(w7)
) {
throw new Exception("设置项目参数非法!");
}
System.out.println("hello");
}
private boolean isZeroOrOne(String s) {
return "0".equals(s) || "1".equals(s);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment