From e397927ab6cad22c94baff80486dfa98d4f5ddfe Mon Sep 17 00:00:00 2001 From: mo Date: Sat, 13 Jul 2019 13:31:34 -0600 Subject: complete question 5 --- src/Q5/ComputeIntellect.java | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'src/Q5/ComputeIntellect.java') diff --git a/src/Q5/ComputeIntellect.java b/src/Q5/ComputeIntellect.java index f195783..d8a7ee7 100644 --- a/src/Q5/ComputeIntellect.java +++ b/src/Q5/ComputeIntellect.java @@ -4,10 +4,43 @@ import java.io.*; import java.util.*; public class ComputeIntellect { - private int doctorate; - private int highschool; - private int postgraduate; - private int undergraduate; + private int doctorate = 0; + private int highschool = 0; + private int postgraduate = 0; + private int undergraduate = 0; - public void distributionOfQualification(Citizen[] citizens) {} + public int getDoctorate() { + return this.doctorate; + } + + public int getHighschool() { + return this.highschool; + } + + public int getPostgraduate() { + return this.postgraduate; + } + + public int getUndergraduate() { + return this.undergraduate; + } + + 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; + } + } + } } -- cgit v1.2.3