Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

# Created by https://www.gitignore.io/api/intellij+all

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

*.iml

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Ruby plugin and RubyMine
/.rakeTasks

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### Intellij+all Patch ###
# Ignores the whole idea folder
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360

.idea/

# End of https://www.gitignore.io/api/intellij+all
38 changes: 38 additions & 0 deletions java/Test/TestFibonacci.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import junit.framework.Assert;
import org.junit.jupiter.api.Test;

public class TestFibonacci{

@Test
public void testCase1(){
int input = 0;
int expectedOutput = 0;
int actualOutput = Fibonacci.findNthFibonacci(input);
Assert.assertEquals(expectedOutput, actualOutput);
}

@Test
public void testCase2(){
int input = 1;
int expectedOutput = 1;
int actualOutput = Fibonacci.findNthFibonacci(input);
Assert.assertEquals(expectedOutput, actualOutput);
}

@Test
public void testCase3(){
int input = 2;
int expectedOutput = 1;
int actualOutput = Fibonacci.findNthFibonacci(input);
Assert.assertEquals(expectedOutput, actualOutput);
}

@Test
public void testCase4(){
int input = 4;
int expectedOutput = 2;
int actualOutput = Fibonacci.findNthFibonacci(input);
Assert.assertEquals(expectedOutput, actualOutput);
}

}
37 changes: 37 additions & 0 deletions java/Test/TestLargestDifference.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import junit.framework.Assert;
import org.junit.jupiter.api.Test;

public class TestLargestDifference{

@Test
public void testCase1(){
int[] inputArray = {1,5,9,16,28,35};
int expectedAnswer = 34;
int actualAnswer = LargestDifference.findLargestDifference(inputArray);
Assert.assertEquals(expectedAnswer, actualAnswer);
}

@Test
public void testCase2(){
int[] inputArray = {7,19,15,13,3};
int expectedAnswer = 12;
int actualAnswer = LargestDifference.findLargestDifference(inputArray);
Assert.assertEquals(expectedAnswer, actualAnswer);
}

@Test
public void testCase3(){
int[] inputArray = {1,1,1,1,1,1,1};
int expectedAnswer = 0;
int actualAnswer = LargestDifference.findLargestDifference(inputArray);
Assert.assertEquals(expectedAnswer, actualAnswer);
}

@Test
public void testCase4(){
int[] inputArray = {5,4,3,2,1};
int expectedAnswer = -1;
int actualAnswer = LargestDifference.findLargestDifference(inputArray);
Assert.assertEquals(expectedAnswer, actualAnswer);
}
}
42 changes: 42 additions & 0 deletions java/Test/TestNumberOfRepeats.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import junit.framework.Assert;
import org.junit.jupiter.api.Test;

public class TestNumberOfRepeats {

@Test
private void testCase1(){
String a = "abcde";
String b = "abcdabcdabcd";
int expectedAnswer = -1;
int actualAnswer = NumberOfRepeats.findNumberOfRepeats(a,b);
Assert.assertEquals(expectedAnswer, actualAnswer);
}

@Test
private void testCase2(){
String a = "abcd";
String b = "abcdabdcabcd";
int expectedAnswer = -1;
int actualAnswer = NumberOfRepeats.findNumberOfRepeats(a,b);
Assert.assertEquals(expectedAnswer, actualAnswer);
}

@Test
private void testCase3(){
String a = "aaab";
String b = "baaabaa";
int expectedAnswer = 3;
int actualAnswer = NumberOfRepeats.findNumberOfRepeats(a,b);
Assert.assertEquals(expectedAnswer, actualAnswer);
}

@Test
private void testCase4(){
String a = "abcde";
String b = "abcdabcdabcd";
int expectedAnswer = -1;
int actualAnswer = NumberOfRepeats.findNumberOfRepeats(a,b);
Assert.assertEquals(expectedAnswer, actualAnswer);
}

}
6 changes: 6 additions & 0 deletions java/src/Fibonacci.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class Fibonacci{
public static int findNthFibonacci(int n){
/* TODO: write your code here */
throw new UnsupportedOperationException();
}
}
6 changes: 6 additions & 0 deletions java/src/LargestDifference.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class LargestDifference{
public static int findLargestDifference(int[] inputArray){
/* TODO: write your code here */
throw new UnsupportedOperationException();
}
}
6 changes: 6 additions & 0 deletions java/src/NumberOfRepeats.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class NumberOfRepeats{
public static int findNumberOfRepeats(String a, String b){
/* TODO: write your code here */
throw new UnsupportedOperationException();
}
}