-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReportCard.java
More file actions
52 lines (42 loc) · 876 Bytes
/
ReportCard.java
File metadata and controls
52 lines (42 loc) · 876 Bytes
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
import java.util.*;
public class ReportCard extends PersonReport implements Report<ArrayList<Double>>{
//Thjs isn't actually supposed to look like a report card.
//A real one would obviously include student objects and course objects
//This file only serves to showcase implementing an interface
private int GPA;
private ArrayList<Double> grades;
public ReportCard(int ID, ArrayList<Double> grades)
{
super(ID);
this.grades=grades;
}
private void findGPA()
{
GPA=0;
if(grades.size()>0)
{
for(int i =0; i<grades.size();i++)
{
GPA+=grades.get(i);
}
GPA/=grades.size();
}
}
public boolean isValid()
{
findGPA();
return GPA>2;
}
public void addData(double data)
{
grades.add(data);
}
public ArrayList<Double> getData()
{
return grades;
}
public void deleteData(double data)
{
grades.remove(data);
}
}