Skip to content

Commit

Permalink
v0
Browse files Browse the repository at this point in the history
  • Loading branch information
jalesmonteiro committed Feb 4, 2021
0 parents commit 1eede1a
Show file tree
Hide file tree
Showing 25 changed files with 200 additions and 0 deletions.
26 changes: 26 additions & 0 deletions atividade_01/pom.xml
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 atividade_01/src/main/java/br/ufrn/imd/triangle/Triangle.java
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 added atividade_02/Icon
Empty file.
Empty file added atividade_02/lib/Icon
Empty file.
Binary file added atividade_02/lib/academic-buggy.jar
Binary file not shown.
Binary file added atividade_02/lib/academic.jar
Binary file not shown.
32 changes: 32 additions & 0 deletions atividade_02/pom.xml
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>
65 changes: 65 additions & 0 deletions atividade_02/spec.json
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 added atividade_02/src/Icon
Empty file.
Empty file added atividade_02/src/main/Icon
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added atividade_02/src/test/Icon
Empty file.
Empty file.
Empty file.
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 added atividade_02/target/Icon
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.

0 comments on commit 1eede1a

Please sign in to comment.