Skip to content
Snippets Groups Projects
Commit d19aaa43 authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Added refactorings from class.

parent 9589d901
No related branches found
No related tags found
No related merge requests found
Showing
with 183 additions and 0 deletions
package edu.unl.cse.soft161.refactored.both_dry_violations;
public class AgeCohort extends Cohort {
private int minimum;
private int maximum;
public AgeCohort(int minimum, int maximum) {
this.minimum = minimum;
this.maximum = maximum;
}
@Override
protected boolean includes(Patient patient) {
return minimum <= patient.getAge() && patient.getAge() <= maximum;
}
}
package edu.unl.cse.soft161.refactored.both_dry_violations;
import java.util.ArrayList;
import java.util.List;
public abstract class Cohort {
protected abstract boolean includes(Patient patient);
public List<Patient> filter(List<Patient> patients) {
List<Patient> results = new ArrayList<Patient>();
for (Patient patient : patients) {
if (includes(patient)) {
results.add(patient);
}
}
return results;
}
}
\ No newline at end of file
package edu.unl.cse.soft161.refactored.both_dry_violations;
public class Patient {
private String name;
private String region;
private int age;
public Patient(String name, String region, int age) {
this.name = name;
this.region = region;
this.age = age;
}
public String getName() {
return name;
}
public String getRegion() {
return region;
}
public int getAge() {
return age;
}
}
package edu.unl.cse.soft161.refactored.both_dry_violations;
public class RegionalCohort extends Cohort {
private String region;
public RegionalCohort(String region) {
this.region = region;
}
@Override
protected boolean includes(Patient patient) {
return patient.getRegion().equals(region);
}
}
package edu.unl.cse.soft161.refactored.dry_violation_in_caller;
public class Bradycardia implements Condition {
@Override
public boolean affects(Patient patient) {
return patient.getObservation("HR") < 60.0;
}
public String toString() {
return "bradycardia";
}
}
package edu.unl.cse.soft161.refactored.dry_violation_in_caller;
public interface Condition {
boolean affects(Patient patient);
}
\ No newline at end of file
package edu.unl.cse.soft161.refactored.dry_violation_in_caller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Patient {
private String name;
private Map<String, Double>observations;
private List<Condition> monitoredConditions;
public Patient(String name, List<Condition>monitoredConditions) {
this.name = name;
observations = new HashMap<String, Double>();
this.monitoredConditions = monitoredConditions;
}
public Double getObservation(String concept) {
return observations.get(concept);
}
public void setObservation(String concept, Double value) {
observations.put(concept, value);
for (Condition condition : monitoredConditions) {
if (condition != null && condition.affects(this)) {
System.out.println("Warning: " + name + " has " + condition + ".");
}
}
}
}
package edu.unl.cse.soft161.refactored.dry_violation_in_caller;
public class Tachycardia implements Condition {
@Override
public boolean affects(Patient patient) {
return patient.getObservation("HR") > 100.0;
}
public String toString() {
return "tachycardia";
}
}
package edu.unl.cse.soft161.refactored.dry_violation_in_method_body;
import java.time.ZonedDateTime;
public class Alert {
private String type;
private String patient;
private ZonedDateTime timestamp;
private String message;
public Alert(String type, String patient, ZonedDateTime timestamp, String message) {
this.type = type;
this.patient = patient;
this.timestamp = timestamp;
this.message = message;
}
public String getType() {
return type;
}
public String getPatient() {
return patient;
}
public ZonedDateTime getTimestamp() {
return timestamp;
}
public String getMessage() {
return message;
}
}
package edu.unl.cse.soft161.refactored.dry_violation_in_method_body;
import java.time.ZonedDateTime;
import java.util.List;
public class SIRSAlert extends Alert {
private List<String> evidence;
public SIRSAlert(String type, String patient, ZonedDateTime timestamp, String message, List<String> evidence) {
super(type, patient, timestamp, message);
this.evidence = evidence;
}
public List<String> getEvidence() {
return evidence;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment