master
1/**
2 * Assignment 2, COMP268 Class: ComputeIntellect.java
3 *
4 * @description A class that can be used to tally the intellect of citizens
5 * @author: mo khan Student ID: 3431709
6 * @date Jul 13, 2019
7 * @version 1.0
8 */
9package Q5;
10
11import java.io.*;
12import java.util.*;
13
14public class ComputeIntellect {
15 private int doctorate = 0;
16 private int highschool = 0;
17 private int postgraduate = 0;
18 private int undergraduate = 0;
19
20 /**
21 * Returns the total # of citizens with a doctorate.
22 *
23 * @return # of citizens with a doctorate
24 */
25 public int getDoctorate() {
26 return this.doctorate;
27 }
28
29 /**
30 * Returns the total # of citizens with a high school diploma.
31 *
32 * @return # of citizens with a high school diploma.
33 */
34 public int getHighschool() {
35 return this.highschool;
36 }
37
38 /**
39 * Returns the total # of citizens with a post graduate degree.
40 *
41 * @return # of citizens with a post graduate degree.
42 */
43 public int getPostgraduate() {
44 return this.postgraduate;
45 }
46
47 /**
48 * Returns the total # of citizens with an under graduate degree.
49 *
50 * @return # of citizens with an under graduate degree.
51 */
52 public int getUndergraduate() {
53 return this.undergraduate;
54 }
55
56 /**
57 * Tallys the # of citizens with different educational qualifications.
58 *
59 * @param citizens the array of citizens to tally.
60 */
61 public void distributionOfQualification(Citizen[] citizens) {
62 for (Citizen citizen : citizens)
63 switch (citizen.getEducationalQualification()) {
64 case Citizen.DOCTORATE:
65 this.doctorate++;
66 break;
67 case Citizen.POSTGRADUATE:
68 this.postgraduate++;
69 break;
70 case Citizen.UNDERGRADUATE:
71 this.undergraduate++;
72 break;
73 case Citizen.HIGH_SCHOOL:
74 this.highschool++;
75 break;
76 }
77 }
78}