-
Notifications
You must be signed in to change notification settings - Fork 0
/
HeadFooter.java
75 lines (70 loc) · 1.86 KB
/
HeadFooter.java
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import java.util.ArrayList;
public class HeadFooter
{
private int header;
private int footer;
private String txt1;
private String txt2;
public HeadFooter(int h, int f, String t1, String t2)
{
header = h;
footer = f;
txt1 = t1;
txt2 = t2;
}
public String headerText1()
{
String Str = "";
ArrayList<String> Sentences = new ArrayList<String>();
Sentences = this.sentenceParser(txt1);
for(int x = 0; x<header; x++)
{
Str += Sentences.get(x) + ".";
}
return Str;
}
public String headerText2()
{
String Str = "";
ArrayList<String> Sentences = new ArrayList<String>();
Sentences = this.sentenceParser(txt2);
for(int x = 0; x<header; x++)
{
Str += Sentences.get(x) + ".";
}
return Str;
}
public String footerText1()
{
String Str = "";
ArrayList<String> Sentences = new ArrayList<String>();
Sentences = this.sentenceParser(txt1);
for(int x = Sentences.size() - footer; x<Sentences.size(); x++)
{
Str += Sentences.get(x) + ".";
}
return Str;
}
public String footerText2()
{
String Str = "";
ArrayList<String> Sentences = new ArrayList<String>();
Sentences = this.sentenceParser(txt2);
for(int x = Sentences.size() - footer; x<Sentences.size(); x++)
{
Str += Sentences.get(x) + ".";
}
return Str;
}
private ArrayList<String> sentenceParser(String str)
{
ArrayList<String> sentences = new ArrayList<String>();
String del = "[.]";
String[] sentence = str.split(del);
for (String s : sentence)
{
sentences.add(s);
}
return sentences;
}
}