-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentList_generics.java
More file actions
65 lines (48 loc) · 1.49 KB
/
StudentList_generics.java
File metadata and controls
65 lines (48 loc) · 1.49 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
58
59
60
61
62
63
64
65
package com.fresco;
import java.util.*;
public class StudentList<Type> {
//Write your code
public ArrayList<Type> studentData;
public StudentList(ArrayList<Type> studentData){
this.studentData=studentData;
}
public void addElement(){
}
public void removeElement(){
}
public Type getElement(){
return null;
}
public ArrayList<Type> beginsWith(String begin_char){
ArrayList<Type> res1 = new ArrayList<Type>();
for(Type temp:studentData){
String temp1 = ((String) temp).toLowerCase();
if(temp1.startsWith(begin_char)) {
res1.add(temp);
}
}
return res1;
}
public ArrayList<Type> bloodGroupOf(String[] blood_groups,String find_blood_group){
ArrayList<Type> res2 = new ArrayList<Type>();
int i=0;
while(i<blood_groups.length) {
if(blood_groups[i].equals(find_blood_group)) {
res2.add(studentData.get(i));
}
i+=1;
}
return res2;
}
public String thresholdScore(int threshold){
ArrayList<Type> res3 = new ArrayList<Type>();
int count=0;
for(Type temp:studentData) {
int temp1=Integer.parseInt((String) temp);
if(temp1>=threshold) {
count+=1;
}
}
return String.format("%d students scored %d above",count,threshold);
}
}