java中等级评比,不知道还有没有bug
package tian;
public class TestMap {
/**
* @Title: main
* @Description: 有关容器
* @param
* @param args
* @return void
* @throws
*/
public static void main(String[] args) {
String str = "AAA+";
String str1 = "BBB+";
System.out.println(doAppraise("A", "AA"));//false
}
public static boolean doAppraise(String str, String str2) {
char appraiseMoody[] = splitString(str);
char appraiseLimit[] = splitString(str2);
boolean result=false;
result=bijiao(appraiseMoody,appraiseLimit);
return result;
}
public static boolean bijiao(char appraiseMoody[],char appraiseLimit[]){
String str3 = "B";
String str4 = "-";
char[] jia = str3.toCharArray();
char[] jian = str4.toCharArray();
int length = appraiseMoody.length;
int lengthLimit = appraiseLimit.length;
boolean result=false;
// 先比较第一个字母是否为+或者-
if((((int) appraiseMoody[0]==jia[0])||((int) appraiseMoody[0]==jia[0]))&&
(((int) appraiseLimit[0]==jia[0])||((int) appraiseLimit[0]==jia[0]))){
shifouxiangt((int) appraiseMoody[0],(int) appraiseLimit[0]);
}else{
if((int) appraiseMoody[0]==(int) appraiseLimit[0]){
//再比较第二个字母
if(length==1&&lengthLimit==1){//先判断长度
return true;
}else if(length==1&&lengthLimit>1){
if((int) appraiseLimit[1]==jia[0]){
return false;
}else{
return false;
}
}else if(length>1&&lengthLimit==1){
if((int) appraiseMoody[0]==jia[0]){
return true;
}else{
return false;
}
}else{
//循环调用
if((((int) appraiseMoody[1]==jia[0])||((int) appraiseMoody[1]==jia[0]))&&
(((int) appraiseLimit[1]==jia[0])||((int) appraiseLimit[1]==jia[0]))){
shifouxiangt((int) appraiseMoody[1],(int) appraiseLimit[1]);
}else{
if((int) appraiseMoody[1]==(int) appraiseLimit[1]){
//再比较第三个字母
if(length==2&&lengthLimit==2){//先判断长度
return true;
}else if(length==2&&lengthLimit>2){
if((int) appraiseLimit[1]==jia[0]){
return false;
}else{
return false;
}
}else if(length>2&&lengthLimit==2){
if((int) appraiseMoody[2]==jia[0]){
return true;
}else if(((int) appraiseMoody[2]>64)&&(int) appraiseMoody[2]<=(int) appraiseMoody[1]){
return true;
}else if((int) appraiseMoody[2]==jian[0]){
return false;
}
}else{
//循环调用
if((((int) appraiseMoody[2]==jia[0])||((int) appraiseMoody[2]==jia[0]))&&
(((int) appraiseLimit[2]==jia[0])||((int) appraiseLimit[2]==jia[0]))){
shifouxiangt((int) appraiseMoody[2],(int) appraiseLimit[2]);
}else{
if((int) appraiseMoody[2]==(int) appraiseLimit[2]){
//再比较第四个字母
if(length==3&&lengthLimit==3){//先判断长度
return true;
}else if(length==3&&lengthLimit>3){
if((int) appraiseLimit[3]==jia[0]){
return false;
}else{
return false;
}
}else if(length>3&&lengthLimit==3){
if((int) appraiseMoody[3]==jia[0]){
return true;
}else{
return false;
}
}else{
return shifouxiangt(appraiseMoody[3],appraiseLimit[3]);
}
}else if(((int) appraiseMoody[2]<64)&&((int) appraiseMoody[2]<(int) appraiseLimit[2])){//。。。。。
return true;
}else if(((int) appraiseMoody[2]<64)&&((int) appraiseLimit[1]<(int) appraiseLimit[2])){
return true;
}else if((int) appraiseMoody[2]<(int) appraiseLimit[2]){
return true;
}else{
return false;
}
}
}
}else if((int) appraiseMoody[1]<(int) appraiseLimit[1]){
return true;
}else{
return false;
}
}
}
}else if((int) appraiseMoody[0]<(int) appraiseLimit[0]){
return true;
}else{
return false;
}
}
return result;
}
public static char[] splitString(String str) {
char[] t = null;
t = str.toCharArray();
return t;
}
//当最后都为+或者-的时候
public static boolean shifouxiangt(int a,int b){
String str3 = "+";
String str4 = "-";
boolean result=false;
char[] jia = str3.toCharArray();
char[] jian = str4.toCharArray();
if((a==jia[0]&&b==jia[0])||(a==jian[0]&&b==jian[0])){
result= true;
}else if((a==jia[0]&&b==jian[0])||(a==jia[0]&&b!=jian[0])){
result= true;
}else {
result= false;
}
return result;
}
}
欢迎关注公众号:Java后端技术全栈