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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
/**
* Assignment 1, COMP268 Class: Candidate.java
*
* @description Represents a candidate
* @author: mo khan Student ID: 3431709
* @date May 8, 2019
* @version 1.0
*/
package Q8;
import Q1.*;
import java.util.ArrayList;
import java.util.Scanner;
public class Candidate extends AddressBook {
private double grade = 0.0;
private Communication communication;
private boolean isInnovative;
private double regulatoryCapability;
/**
* Constructs a Candidate object.
*
* @param firstName the first name of the runner
* @param lastName the last name of the runner
* @param grade the grade for the candidate
* @param communication the level of communication
* @param isInnovative specifies if the candidate is innovative.
* @param regulatoryCapability specifies the candidates level of regulatory capability
*/
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;
}
/** @return the candidates innovativeness. */
public boolean isInnovative() {
return this.isInnovative;
}
/** @return the candidates grade. */
public double getGrade() {
return this.grade;
}
/** @return the candidates regulatory capability */
public double getRegulation() {
return this.regulatoryCapability;
}
/** @return the candidates communication ability */
public String getCommunication() {
return this.communication.toString();
}
/**
* Sets the candidate communication level.
*
* @param communication the candidates communication ability
*/
public void setCommunication(String communication) {
this.communication = Communication.findBy(communication);
}
/**
* Sets the candidate grade level.
*
* @param grade the candidates grade
*/
public void setGrade(double grade) {
this.grade = grade;
}
/**
* Sets the candidate innovation level.
*
* @param innovation the candidates innovation ability
*/
public void setInnovation(boolean innovation) {
this.isInnovative = innovation;
}
/**
* Sets the candidate regulatory capability level.
*
* @param regulatoryCapability the candidates regulatory capability
*/
public void setRegulation(double regulatoryCapability) {
this.regulatoryCapability = regulatoryCapability;
}
/** @return true if the candidate is eligible for a position at the company. */
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));
}
}
/**
* @param candidates the list of candidates to check for qualifications
* @return a list of candidates that are eligible for employment at the company.
*/
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;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Candidate[] candidates = {
new Candidate("Elena", "Brandon", 82.30, "poor", true, 0.5),
new Candidate("Thomas", "Molson", 85.10, "poor", false, 1.0),
new Candidate("Hamilton", "Winn", 77.77, "average", false, 0.8),
new Candidate("Suzie", "Sarandin", 69.93, "average", false, 0.0),
new Candidate("Philip", "Winne", 93.03, "average", true, 1.0),
new Candidate("Alex", "Trebok", 88.61, "poor", true, 0.7),
new Candidate("Emma", "Pivoto", 55.99, "excellent", false, 0.8),
new Candidate("John", "Lenthen", 87.49, "excellent", true, 0.9),
new Candidate("James", "Lean", 88.00, "excellent", false, 0.5),
new Candidate("Jane", "Ostin", 91.20, "average", true, 0.6),
new Candidate("Emily", "Car", 66.79, "excellent", false, 0.3),
new Candidate("Daniel", "Hamshire", 76.65, "average", true, 0.2),
new Candidate("Neda", "Bazdar", 55.89, "excellent", true, 0.5),
new Candidate("Aaron", "Smith", 90.01, "excellent", false, 0.3),
new Candidate("Kate", "Hen", 87.9, "poor", false, 0.8)
};
for (Candidate candidate : Candidate.getEligibleCandidates(candidates))
System.out.println(candidate);
}
}
|