summaryrefslogtreecommitdiff
path: root/src/Q8/Candidate.java
blob: 7df953576cab5dfe6c5ac3675505f6d455b7788f (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
package ca.mokhan.assignment1;

import java.util.ArrayList;

public class Candidate extends AddressBook {
  private double grade = 0.0;
  private Communication communication;
  private boolean isInnovative;
  private double regulatoryCapability;

  public Candidate(
      String firstName,
      String lastName,
      double grade,
      String communication,
      boolean isInnovative,
      double regulatoryCapability) {
    super(firstName, "", lastName);
    this.grade = grade;
    this.setCommunication(communication);
    this.isInnovative = isInnovative;
    this.regulatoryCapability = regulatoryCapability;
  }

  public boolean isInnovative() {
    return this.isInnovative;
  }

  public double getGrade() {
    return this.grade;
  }

  public double getRegulation() {
    return this.regulatoryCapability;
  }

  public String getCommunication() {
    return this.communication.toString();
  }

  public void setCommunication(String communication) {
    this.communication = Communication.findBy(communication);
  }

  public void setGrade(double grade) {
    this.grade = grade;
  }

  public void setInnovation(boolean innovation) {
    this.isInnovative = innovation;
  }

  public void setRegulation(double regulatoryCapability) {
    this.regulatoryCapability = regulatoryCapability;
  }

  public boolean isEligible() {
    if (this.grade >= 85.0) {
      return this.communication.isAtLeast(Communication.Average) || this.isInnovative();
    } else {
      return (this.regulatoryCapability >= 0.5
          && this.communication.isAtLeast(Communication.Average));
    }
  }

  public static ArrayList<Candidate> getEligibleCandidates(Candidate[] candidates) {
    ArrayList<Candidate> eligible = new ArrayList<Candidate>();

    for (Candidate candidate : candidates) {
      if (candidate.isEligible()) eligible.add(candidate);
    }

    return eligible;
  }
}