blob: 64d5a076cab47546d1700eabf50d4e9a3ce8d215 (
plain)
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
76
77
78
|
/**
* Assignment 2, COMP268 Class: ComputeIntellect.java
*
* @description A class that can be used to tally the intellect of citizens
* @author: mo khan Student ID: 3431709
* @date Jul 13, 2019
* @version 1.0
*/
package Q5;
import java.io.*;
import java.util.*;
public class ComputeIntellect {
private int doctorate = 0;
private int highschool = 0;
private int postgraduate = 0;
private int undergraduate = 0;
/**
* Returns the total # of citizens with a doctorate.
*
* @return # of citizens with a doctorate
*/
public int getDoctorate() {
return this.doctorate;
}
/**
* Returns the total # of citizens with a high school diploma.
*
* @return # of citizens with a high school diploma.
*/
public int getHighschool() {
return this.highschool;
}
/**
* Returns the total # of citizens with a post graduate degree.
*
* @return # of citizens with a post graduate degree.
*/
public int getPostgraduate() {
return this.postgraduate;
}
/**
* Returns the total # of citizens with an under graduate degree.
*
* @return # of citizens with an under graduate degree.
*/
public int getUndergraduate() {
return this.undergraduate;
}
/**
* Tallys the # of citizens with different educational qualifications.
*
* @param citizens the array of citizens to tally.
*/
public void distributionOfQualification(Citizen[] citizens) {
for (Citizen citizen : citizens)
switch (citizen.getEducationalQualification()) {
case Citizen.DOCTORATE:
this.doctorate++;
break;
case Citizen.POSTGRADUATE:
this.postgraduate++;
break;
case Citizen.UNDERGRADUATE:
this.undergraduate++;
break;
case Citizen.HIGH_SCHOOL:
this.highschool++;
break;
}
}
}
|