-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1eede1a
Showing
25 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>Triangle</groupId> | ||
<artifactId>triangle</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>triangle</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
55 changes: 55 additions & 0 deletions
55
atividade_01/src/main/java/br/ufrn/imd/triangle/Triangle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package br.ufrn.imd.triangle; | ||
|
||
public class Triangle { | ||
|
||
public enum TriangleType { | ||
NOT_TRIANGLE, EQUILATERAL, ISOCELES, SCALENE; | ||
} | ||
|
||
public Triangle() { | ||
super(); | ||
} | ||
|
||
private boolean allEqualSides(Integer s1, Integer s2, Integer s3) { | ||
return s1 == s2 && s2 == s3; | ||
} | ||
|
||
private boolean anyNegative(Integer s1, Integer s2, Integer s3) { | ||
return s1 < 0 || s2 < 0 || s3 < 0; | ||
} | ||
|
||
private boolean anyNull(Integer s1, Integer s2, Integer s3) { | ||
return s1 == null || s2 == null || s3 == null; | ||
} | ||
|
||
public TriangleType defineType(Integer s1, Integer s2, Integer s3) { | ||
if (anyNull(s1, s2, s3)) { | ||
throw new NullPointerException(); | ||
} | ||
|
||
if (anyNegative(s1, s2, s3)) { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
if (oneSideLargerThanSumOfOthers(s1, s2, s3)) { | ||
return TriangleType.NOT_TRIANGLE; | ||
} | ||
else if (allEqualSides(s1, s2, s3)) { | ||
return TriangleType.EQUILATERAL; | ||
} | ||
else if (twoEqualSides(s1, s2, s3)) { | ||
return TriangleType.ISOCELES; | ||
} | ||
else { | ||
return TriangleType.SCALENE; | ||
} | ||
} | ||
|
||
private boolean oneSideLargerThanSumOfOthers(Integer s1, Integer s2, Integer s3) { | ||
return s1 > s2 + s3 || s2 > s1 + s3 || s3 > s1 + s2; | ||
} | ||
|
||
private boolean twoEqualSides(Integer s1, Integer s2, Integer s3) { | ||
return s1 == s2 || s1 == s3 || s2 == s3; | ||
} | ||
} |
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>imd0412</groupId> | ||
<artifactId>academic</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>academic</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>imdtest</groupId> | ||
<artifactId>academiclib</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<scope>system</scope> | ||
<systemPath>${project.basedir}/lib/academic-buggy.jar</systemPath> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
[{ | ||
"operation": { | ||
"classname": "imd0412.academic.GradeModule", | ||
"name": "performPartialConsolidation", | ||
"parameterTypes": [ | ||
"java.lang.Float", "java.lang.Float", "java.lang.Float", "java.lang.Integer" | ||
] | ||
}, | ||
"identifiers": { | ||
"parameters": ["grade1", "grade2", "grade3", "attendanceFrequency"], | ||
"receiverName": "receiver", | ||
"returnName": "result" | ||
}, | ||
"throws": [], | ||
"post": [ | ||
{ | ||
"property": { | ||
"condition": "result == ApprovalStatus.REPF || result == ApprovalStatus.REP || result == ApprovalStatus.REC || result == ApprovalStatus.APR || result == ApprovalStatus.APRN || result == ApprovalStatus.REMF", | ||
"description": "result is enum" | ||
}, | ||
"description": "returns enum", | ||
"guard": { | ||
"condition": "true", | ||
"description": "" | ||
} | ||
} | ||
], | ||
"pre": [ | ||
{ | ||
"description": "grade1", | ||
"guard": { | ||
"condition": "grade1 >= 0.0f && grade1 <= 10.0f && grade1 != null", | ||
"description": "grade1" | ||
} | ||
}, | ||
{ | ||
"description": "grade2", | ||
"guard": { | ||
"condition": "grade2 >= 0.0f && grade2 <= 10.0f && grade2 != null", | ||
"description": "grade2" | ||
} | ||
}, | ||
{ | ||
"description": "grade3", | ||
"guard": { | ||
"condition": "grade3 >= 0.0f && grade3 <= 10.0f && grade3 != null", | ||
"description": "grade3" | ||
} | ||
}, | ||
{ | ||
"description": "grade3", | ||
"guard": { | ||
"condition": "grade3 >= 0.0f && grade3 <= 10.0f && grade3 != null", | ||
"description": "grade3" | ||
} | ||
}, | ||
{ | ||
"description": "attendanceFrequency", | ||
"guard": { | ||
"condition": "attendanceFrequency >= 0 && attendanceFrequency <= 100 && attendanceFrequency != null", | ||
"description": "attendanceFrequency" | ||
} | ||
} | ||
] | ||
}] |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
22 changes: 22 additions & 0 deletions
22
atividade_02/src/test/java/imd0412/academic/GradeModuleNormalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package imd0412.academic; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
public class GradeModuleNormalTest { | ||
|
||
@Test | ||
public void test() { | ||
final Float grade1 = 4.7f; | ||
final Float grade2 = 5.1f; | ||
final Float grade3 = 6.0f; | ||
final Integer attendanceFrequency = 80; | ||
|
||
final ApprovalStatus status = GradeModule.performPartialConsolidation(grade1, grade2, grade3, | ||
attendanceFrequency); | ||
|
||
assertEquals(ApprovalStatus.APRN, status); | ||
} | ||
|
||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.