Brandon Defrancis 6 лет назад
Родитель
Сommit
4320f40d99

+ 2
- 0
.idea/compiler.xml Просмотреть файл

@@ -7,10 +7,12 @@
7 7
         <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
8 8
         <outputRelativeToContentRoot value="true" />
9 9
         <module name="bankaccountlab" />
10
+        <module name="productmanager" />
10 11
       </profile>
11 12
     </annotationProcessing>
12 13
     <bytecodeTargetLevel target="1.8">
13 14
       <module name="bankaccountlab" target="1.5" />
15
+      <module name="productmanager" target="1.5" />
14 16
     </bytecodeTargetLevel>
15 17
   </component>
16 18
 </project>

+ 13
- 0
.idea/libraries/Maven__junit_junit_4_12.xml Просмотреть файл

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: junit:junit:4.12">
3
+    <CLASSES>
4
+      <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml Просмотреть файл

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: org.hamcrest:hamcrest-core:1.3">
3
+    <CLASSES>
4
+      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 0
- 61
.idea/misc.xml Просмотреть файл

@@ -64,65 +64,4 @@
64 64
   <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
65 65
     <output url="file://$PROJECT_DIR$/out" />
66 66
   </component>
67
-  <component name="masterDetails">
68
-    <states>
69
-      <state key="GlobalLibrariesConfigurable.UI">
70
-        <settings>
71
-          <splitter-proportions>
72
-            <option name="proportions">
73
-              <list>
74
-                <option value="0.2" />
75
-              </list>
76
-            </option>
77
-          </splitter-proportions>
78
-        </settings>
79
-      </state>
80
-      <state key="JdkListConfigurable.UI">
81
-        <settings>
82
-          <last-edited>1.8</last-edited>
83
-          <splitter-proportions>
84
-            <option name="proportions">
85
-              <list>
86
-                <option value="0.2" />
87
-              </list>
88
-            </option>
89
-          </splitter-proportions>
90
-        </settings>
91
-      </state>
92
-      <state key="ProjectJDKs.UI">
93
-        <settings>
94
-          <last-edited>1.8</last-edited>
95
-          <splitter-proportions>
96
-            <option name="proportions">
97
-              <list>
98
-                <option value="0.2" />
99
-              </list>
100
-            </option>
101
-          </splitter-proportions>
102
-        </settings>
103
-      </state>
104
-      <state key="ProjectLibrariesConfigurable.UI">
105
-        <settings>
106
-          <splitter-proportions>
107
-            <option name="proportions">
108
-              <list>
109
-                <option value="0.2" />
110
-              </list>
111
-            </option>
112
-          </splitter-proportions>
113
-        </settings>
114
-      </state>
115
-      <state key="ScopeChooserConfigurable.UI">
116
-        <settings>
117
-          <splitter-proportions>
118
-            <option name="proportions">
119
-              <list>
120
-                <option value="0.2" />
121
-              </list>
122
-            </option>
123
-          </splitter-proportions>
124
-        </settings>
125
-      </state>
126
-    </states>
127
-  </component>
128 67
 </project>

+ 1
- 1
.idea/modules.xml Просмотреть файл

@@ -2,7 +2,7 @@
2 2
 <project version="4">
3 3
   <component name="ProjectModuleManager">
4 4
     <modules>
5
-      <module fileurl="file://$PROJECT_DIR$/bankaccountlab.iml" filepath="$PROJECT_DIR$/bankaccountlab.iml" />
5
+      <module fileurl="file://$PROJECT_DIR$/productmanager.iml" filepath="$PROJECT_DIR$/productmanager.iml" />
6 6
     </modules>
7 7
   </component>
8 8
 </project>

+ 539
- 413
.idea/workspace.xml
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 9
- 0
pom.xml Просмотреть файл

@@ -8,5 +8,14 @@
8 8
     <artifactId>productmanager</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10 10
 
11
+    <dependencies><!-- https://mvnrepository.com/artifact/junit/junit -->
12
+        <dependency>
13
+            <groupId>junit</groupId>
14
+            <artifactId>junit</artifactId>
15
+            <version>4.12</version>
16
+            <scope>test</scope>
17
+        </dependency>
18
+
19
+    </dependencies>
11 20
 
12 21
 </project>

+ 44
- 0
src/main/java/com/zipcodewilmington/productmanager/Inventory.java Просмотреть файл

@@ -0,0 +1,44 @@
1
+package com.zipcodewilmington.productmanager;
2
+
3
+import java.util.ArrayList;
4
+
5
+public class Inventory {
6
+
7
+    private ArrayList<Product> productList;
8
+
9
+    public Inventory(ArrayList<Product> productList) {
10
+        productList = productList;
11
+    }
12
+
13
+    public Inventory() {
14
+
15
+        productList = new ArrayList<Product>(0);
16
+
17
+    }
18
+
19
+    public ArrayList<Product> getProductList() {
20
+        return productList;
21
+    }
22
+
23
+    public void setProductList(ArrayList<Product> startingInventory) {
24
+        productList = startingInventory;
25
+    }
26
+
27
+    public int sumOfInventory() {
28
+
29
+        int inventoryValue = 0;
30
+
31
+        for (int i =0; i < productList.size(); i++){
32
+                inventoryValue += productList.get(i).getQuantity() * productList.get(i).getPrice();
33
+
34
+        }
35
+        return inventoryValue;
36
+
37
+    }
38
+
39
+    public void addProduct(Product productToAdd) {
40
+
41
+        productList.add(productToAdd);
42
+
43
+    }
44
+}

+ 5
- 0
src/main/java/com/zipcodewilmington/productmanager/MainApplication.java Просмотреть файл

@@ -4,4 +4,9 @@ package com.zipcodewilmington.productmanager;
4 4
  * Created by leon on 1/10/18.
5 5
  */
6 6
 public class MainApplication {
7
+
8
+
9
+
10
+
11
+
7 12
 }

+ 36
- 0
src/main/java/com/zipcodewilmington/productmanager/Product.java Просмотреть файл

@@ -4,4 +4,40 @@ package com.zipcodewilmington.productmanager;
4 4
  * Created by leon on 1/10/18.
5 5
  */
6 6
 public class Product {
7
+
8
+    private int price;
9
+    private int id;
10
+    private int quantity;
11
+
12
+
13
+    public Product(int price, int id, int quantity) {
14
+        this.price = price;
15
+        this.id = id;
16
+        this.quantity = quantity;
17
+    }
18
+
19
+    public int getPrice() {
20
+
21
+        return price;
22
+    }
23
+
24
+    public void setPrice(int price) {
25
+        this.price = price;
26
+    }
27
+
28
+    public int getId() {
29
+        return id;
30
+    }
31
+
32
+    public void setId(int id) {
33
+        this.id = id;
34
+    }
35
+
36
+    public int getQuantity() {
37
+        return quantity;
38
+    }
39
+
40
+    public void setQuantity(int quantity) {
41
+        this.quantity = quantity;
42
+    }
7 43
 }

+ 53
- 0
src/test/java/com/zipcodewilmington/productmanager/InventoryTest.java Просмотреть файл

@@ -0,0 +1,53 @@
1
+package com.zipcodewilmington.productmanager;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+import static org.junit.Assert.*;
7
+
8
+public class InventoryTest {
9
+
10
+    @Test
11
+    public void getProductList() {
12
+    }
13
+
14
+    @Test
15
+    public void setProductList() {
16
+    }
17
+
18
+    @Test
19
+    public void sumOfInventory() {
20
+
21
+        Inventory test = new Inventory();
22
+        int actual = test.sumOfInventory();
23
+        int expected = 0;
24
+
25
+        Assert.assertEquals(actual, expected);
26
+    }
27
+
28
+    @Test
29
+    public void sumOfInventory1() {
30
+
31
+        Product apples = new Product(1, 129930, 30);
32
+        Inventory test = new Inventory();
33
+        test.addProduct(apples);
34
+        int actual = test.sumOfInventory();
35
+        int expected = 30;
36
+
37
+        Assert.assertEquals(actual, expected);
38
+    }
39
+
40
+    @Test
41
+    public void sumOfInventory2() {
42
+
43
+        Product apples = new Product(1, 129930, 45);
44
+        Product lambos = new Product(400, 209949, 10);
45
+        Inventory test = new Inventory();
46
+        test.addProduct(apples);
47
+        test.addProduct(lambos);
48
+        int actual = test.sumOfInventory();
49
+        int expected = 4045;
50
+
51
+        Assert.assertEquals(actual, expected);
52
+    }
53
+}

+ 6
- 1
src/test/java/com/zipcodewilmington/productmanager/ProductTest.java Просмотреть файл

@@ -1,7 +1,12 @@
1 1
 package com.zipcodewilmington.productmanager;
2
-
2
+import org.junit.Test;
3
+import org.junit.Assert;
3 4
 /**
4 5
  * Created by leon on 1/10/18.
5 6
  */
6 7
 public class ProductTest {
8
+
9
+
10
+
11
+
7 12
 }