-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManagementCttee.java
More file actions
44 lines (40 loc) · 1.39 KB
/
ManagementCttee.java
File metadata and controls
44 lines (40 loc) · 1.39 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
public class ManagementCttee {
// fields
private SeniorMember[] ctteeMembers;
// variable to hold index
private int numRecords = 0;
public ManagementCttee() {
// initialize the array with maximum of 100 members
ctteeMembers = new SeniorMember[100];
}
/**
* Add SeniorMember to the array
*
*/
public void addMember(SeniorMember s) {
if (numRecords < ctteeMembers.length) {
ctteeMembers[numRecords] = s;
numRecords++;
}
}
/**
* Removes a SeniorMember with the passed name from array
*
*/
public void removeCtteeMember(String name) {
// iterate from first till end of the array
for (int index = 0; index < numRecords; index++) {
// check if name matches
if (ctteeMembers[index].getName().equalsIgnoreCase(name)) {
// iterate from removeIndex till end of the array
for (int removeIndex = index; removeIndex < numRecords; removeIndex++) {
// assign next index element to current index
ctteeMembers[removeIndex] = ctteeMembers[removeIndex + 1];
}
ctteeMembers[numRecords - 1] = null;
// decrement the number of records by 1
numRecords -= 1;
}
}
}
}