Explorar el Código

initial commit. first method/test written

jasamuels hace 6 años
padre
commit
7a79d750ba
Se han modificado 3 ficheros con 54 adiciones y 16 borrados
  1. 0
    16
      arraz/arraz.iml
  2. 41
    0
      arraz/src/main/java/Arraz.java
  3. 13
    0
      arraz/src/test/java/ArrazTest.java

+ 0
- 16
arraz/arraz.iml Ver fichero

@@ -1,16 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3
-  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
4
-    <output url="file://$MODULE_DIR$/target/classes" />
5
-    <output-test url="file://$MODULE_DIR$/target/test-classes" />
6
-    <content url="file://$MODULE_DIR$">
7
-      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8
-      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
9
-      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
10
-      <excludeFolder url="file://$MODULE_DIR$/target" />
11
-    </content>
12
-    <orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
13
-    <orderEntry type="sourceFolder" forTests="false" />
14
-    <orderEntry type="library" name="Maven: junit:junit:4.0" level="project" />
15
-  </component>
16
-</module>

+ 41
- 0
arraz/src/main/java/Arraz.java Ver fichero

@@ -1,2 +1,43 @@
1 1
 public class Arraz {
2
+
3
+    public static int sumValuesOfArray (int[] array){
4
+
5
+        int sum = 0;
6
+
7
+        for (int i : array)
8
+        {
9
+            sum += i;
10
+        }
11
+        return sum;
12
+    }
13
+
14
+//            sumDoublesOfArray
15
+//    averageOfArray
16
+//            doubleAverageOfArray
17
+//    containsValue
18
+//            reverseArray
19
+//    getOddEvensOfArray
20
+//            findIndexOf
21
+//    copyArrayByIterator
22
+//            copyArrayByLoop
23
+//    removeElementFromArray
24
+//            insertIntoArrayAt
25
+//    findMaxMinOfArray
26
+//            removeDupesFromArray
27
+//    find2ndLargestValueFromArray
28
+//            makeMeAnArrayListFromArray
29
+//    makeMeAnArrayFromArrayList
30
+//            check2ArraysForEqual
31
+//    averageArrayWithoutMaxMin
32
+//            arrayHas65and77
33
+//    theTotalofTensIs30
34
+//            findSmallest
35
+//    findSecondSmallest
36
+//            makeMeACopyPlease
37
+//    removeLastItemAndCopy
38
+//            removeFirstItemAndCopy
39
+//    insertAtStartAndCopy
40
+//            insertAtEndAndCopy
41
+//    sortArrayIntoEvensThenOdds
42
+
2 43
 }

+ 13
- 0
arraz/src/test/java/ArrazTest.java Ver fichero

@@ -1,5 +1,18 @@
1
+import junit.framework.Assert;
2
+import org.junit.Test;
3
+
1 4
 import static org.junit.Assert.*;
2 5
 
3 6
 public class ArrazTest {
4 7
 
8
+    int[] spiffyHandyIntArray = new int[] {4,5,102,6,-7,12,-32,92,8};
9
+
10
+    @Test
11
+    public void sumValuesOfArray() {
12
+
13
+        int sum = 190;
14
+
15
+        Assert.assertEquals(sum, Arraz.sumValuesOfArray(spiffyHandyIntArray));
16
+
17
+    }
5 18
 }