-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSE360.java
More file actions
57 lines (54 loc) · 1.1 KB
/
CSE360.java
File metadata and controls
57 lines (54 loc) · 1.1 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.util.*;
private ArrayList<String> centerJustify(){
ArrayList<String> list = new ArrayList<String>();
String temp= "";
int size;
if(column1)
size = 80;
else
size = 35;
for(int i=0; i< paragraph.size(); i++) {
String line= paragraph.get(i);
String [] words= line.split(" ");
for(int j=0; j< words.length; j++) {
String add= words[j];
if(temp.length() + add.length() +1 >size) {
while(temp.length() <size) {
temp= " "+temp+" ";
}
list.add(temp);
if(!single && column1)
list.add("");
temp= "";
temp= temp + add;
}
else {
if(temp.length() == 0) {
temp= temp + add;
}
else {
temp= temp +" "+ add;
}
}
}
}
if(temp.length()>0) {
while (temp.length() <size) {
temp= " " +temp+" ";
}
list.add(temp);
}
return list;
}
private void formatTwoColumns(ArrayList<String> lines) {
for (int i=0; i<2; i++){
int length =MATH;
.max(
maxLengths.get(i),
lines[i].length()
);
maxLengths.set(i, length);
}
lines.add(Arrays.asList(line));
return this;
}