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

Initial commit.

parents
Branches
Tags
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.project 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>buggyTransitSimulator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
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.soft160.triangle_classifier</groupId>
<artifactId>triangleClassifier</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>triangleClassifier</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>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
package edu.unl.cse.soft160.triangle_classifier;
import java.util.Scanner;
public class TriangleClassifier {
private enum Classification {
INVALID, EQUILATERAL, ISOSCELES, RIGHT, SCALENE,
}
public static Classification classify(int a, int b, int c) { // buggy
if (a * b * c < 0) {
return Classification.INVALID;
}
if (a == b && b == c) {
return Classification.EQUILATERAL;
}
if (a == b || b == c) {
return Classification.ISOSCELES;
}
int maximum = a;
if (b > maximum) {
maximum = b;
if (c > maximum) {
maximum = c;
}
}
double semiperimeter = a + b + c / 2.0;
if (maximum > semiperimeter) {
return Classification.INVALID;
}
if (a * a + b * b == c * c || b * b + a * a == c * c || c * c + b * b == a * a) {
return Classification.RIGHT;
}
return Classification.SCALENE;
}
public static void main(String... arguments) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter first side length: ");
int firstLength = Integer.parseInt(scanner.nextLine());
System.out.print("Enter second side length: ");
int secondLength = Integer.parseInt(scanner.nextLine());
System.out.print("Enter third side length: ");
int thirdLength = Integer.parseInt(scanner.nextLine());
scanner.close();
System.out.println("Classification: " + classify(firstLength, secondLength, thirdLength));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment