-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGradeSection.java
More file actions
executable file
·48 lines (38 loc) · 1.23 KB
/
GradeSection.java
File metadata and controls
executable file
·48 lines (38 loc) · 1.23 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
import java.util.ArrayList;
/* This class represents a specific grade section in the rubric such as Style,
* Design, or Correctness
*/
public class GradeSection {
private String name;
private ArrayList<GradeItem> children; // All sub grade items within the section
// Constructor validates the string input before setting the name
public GradeSection(String n) {
name = validate(n);
children = new ArrayList<GradeItem>();
}
// Converts strings with "marks}" or "mark}" in it to just the name
private static String validate(String n) {
String[] broken = n.split(" ");
String valid = "";
try {
for (int i = 0; i < broken.length; i++) {
if (broken[i].charAt(0) == '{')
break;
valid += broken[i] + " "; // The spaces were removed, so add a new one
}
}
catch (Exception e) {}
return valid;
}
public void addGradeItem(String s) {
children.add(new GradeItem(s));
}
public String toString() {
return name;
}
public GradeItem[] getGradeItems() {
GradeItem[] items = new GradeItem[children.size()];
items = children.toArray(items);
return items;
}
}