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

Initial commit.

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 249 additions and 0 deletions
target/
.classpath
.project
.settings
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
pom.xml 0 → 100644
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.unl.cse.soft161.inheritance_examples</groupId>
<artifactId>inheritance_examples</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>inheritance_examples</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
package edu.unl.cse.soft161.inheritance_examples.both_dry_violations;
import java.util.ArrayList;
import java.util.List;
public class AgeCohort {
private int minimum;
private int maximum;
public AgeCohort(int minimum, int maximum) {
this.minimum = minimum;
this.maximum = maximum;
}
private boolean includesByAge(Patient patient) {
return minimum <= patient.getAge() && patient.getAge() <= maximum;
}
public List<Patient> filter(List<Patient> patients) {
List<Patient> results = new ArrayList<Patient>();
for (Patient patient : patients) {
if (includesByAge(patient)) {
results.add(patient);
}
}
return results;
}
}
package edu.unl.cse.soft161.inheritance_examples.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.inheritance_examples.both_dry_violations;
import java.util.ArrayList;
import java.util.List;
public class RegionalCohort {
private String region;
public RegionalCohort(String region) {
this.region = region;
}
private boolean includesByRegion(Patient patient) {
return patient.getRegion().equals(region);
}
public List<Patient> filter(List<Patient> patients) {
List<Patient> results = new ArrayList<Patient>();
for (Patient patient : patients) {
if (includesByRegion(patient)) {
results.add(patient);
}
}
return results;
}
}
package edu.unl.cse.soft161.inheritance_examples.dry_violation_in_caller;
public class Bradycardia {
public boolean affects(Patient patient) {
return patient.getObservation("HR") < 60.0;
}
public String toString() {
return "bradycardia";
}
}
package edu.unl.cse.soft161.inheritance_examples.dry_violation_in_caller;
import java.util.HashMap;
import java.util.Map;
public class Patient {
private String name;
private Map<String, Double>observations;
private Bradycardia bradycardia;
private Tachycardia tachycardia;
public Patient(String name, Bradycardia bradycardia, Tachycardia tachycardia) {
this.name = name;
observations = new HashMap<String, Double>();
this.bradycardia = bradycardia;
this.tachycardia = tachycardia;
}
public Double getObservation(String concept) {
return observations.get(concept);
}
public void setObservation(String concept, Double value) {
observations.put(concept, value);
if (bradycardia != null && bradycardia.affects(this)) {
System.out.println("Warning: " + name + " has " + bradycardia + ".");
}
if (tachycardia != null && tachycardia.affects(this)) {
System.out.println("Warning: " + name + " has " + tachycardia + ".");
}
}
}
package edu.unl.cse.soft161.inheritance_examples.dry_violation_in_caller;
public class Tachycardia {
public boolean affects(Patient patient) {
return patient.getObservation("HR") > 100.0;
}
public String toString() {
return "tachycardia";
}
}
package edu.unl.cse.soft161.inheritance_examples.dry_violation_in_method_body;
import java.time.ZonedDateTime;
public class GeneralAlert {
private String type;
private String patient;
private ZonedDateTime timestamp;
private String message;
public GeneralAlert(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.inheritance_examples.dry_violation_in_method_body;
import java.time.ZonedDateTime;
import java.util.List;
public class SIRSAlert {
private String type;
private String patient;
private ZonedDateTime timestamp;
private String message;
private List<String> evidence;
public SIRSAlert(String type, String patient, ZonedDateTime timestamp, String message, List<String> evidence) {
this.type = type;
this.patient = patient;
this.timestamp = timestamp;
this.message = message;
this.evidence = evidence;
}
public String getType() {
return type;
}
public String getPatient() {
return patient;
}
public ZonedDateTime getTimestamp() {
return timestamp;
}
public String getMessage() {
return message;
}
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