Skip to content
Snippets Groups Projects
Commit fee8b3be authored by Teemu Kallinen's avatar Teemu Kallinen
Browse files

New addon

parents
No related branches found
No related tags found
No related merge requests found
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="22" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings" defaultProject="true" />
</project>
\ No newline at end of file
pom.xml 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<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>fi.utu.tjmkal</groupId>
<artifactId>Week4-E1</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package fi.utu.tjmkal;
public class Calculator {
int result;
public Calculator() {
reset();
}
public void reset() {
this.result = 0;
}
public int getResult() {
return this.result;
}
public void add(int value) {
this.result += value;
}
public void subtract(int value) {
this.result -= value;
}
public void multiply(int value) {
this.result *= value;
}
public void exponent(int value) {
while (value != 1) {
result *= result;
--value;
}
}
}
package fi.utu.tjmkal;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
\ No newline at end of file
package fi.utu.tjmkal;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class CalculatorTest {
@Test
void reset() {
}
@Test
void getResult() {
Calculator calculator = new Calculator();
assertEquals(0, calculator.getResult());
}
@Test
void add() {
Calculator calculator = new Calculator();
calculator.add(10);
calculator.add(-5);
assertEquals(5, calculator.getResult());
}
@Test
void subtract() {
Calculator calculator = new Calculator();
calculator.add(10);
calculator.subtract(5);
assertEquals(5, calculator.getResult());
}
@Test
void multiply() {
Calculator calculator = new Calculator();
calculator.add(5);
calculator.multiply(2);
calculator.multiply(-3);
assertEquals(-30, calculator.getResult());
}
@Test
void exponent() {
Calculator calculator = new Calculator();
calculator.add(10);
calculator.exponent(3);
assertEquals(10000, calculator.getResult());
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment