-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoveString.java
More file actions
36 lines (33 loc) · 1.18 KB
/
MoveString.java
File metadata and controls
36 lines (33 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public class MoveString {
public static String[] Sheets = new String[256];
public static int move(String from, String to, boolean before) {
Sheets[0] = "Sheet1";
Sheets[1] = "Sheet2";
Sheets[2] = "Sheet3";
String temp = null;
if((from.toUpperCase()).equals(to.toUpperCase()) == false) {
for(int a = 0; a < Sheets.length; a++) {
if(Sheets[a] != null) {
if((Sheets[a].toUpperCase()).equals(from.toUpperCase())) {
temp = from;
Sheets[a] = null;
}
}
}
for(int b = 0; b < Sheets.length; b++) {
if(Sheets[b] != null) {
if((Sheets[b].toUpperCase()).equals((to.toUpperCase()))) {
if(before == true) {
Sheets[b-1] = temp;
return b - 1;
} else {
Sheets[b+1] = temp;
return b + 1;
}
}
}
}
}
return -1;
}
}