Bläddra i källkod

Elliott Stansbury final changes

Elliott Stansbury 6 år sedan
förälder
incheckning
95a6cf6ab1

+ 2
- 1
.idea/compiler.xml Visa fil

@@ -7,10 +7,11 @@
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
-      <module name="bankaccountlab" target="1.5" />
14
+      <module name="productmanager" target="8" />
14 15
     </bytecodeTargetLevel>
15 16
   </component>
16 17
 </project>

+ 13
- 0
.idea/libraries/Maven__junit_junit_4_12.xml Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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>

+ 519
- 391
.idea/workspace.xml
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 8
- 0
pom.xml Visa fil

@@ -7,6 +7,14 @@
7 7
     <groupId>com.zipcodewilmington</groupId>
8 8
     <artifactId>productmanager</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10
+    <dependencies>
11
+        <dependency>
12
+            <groupId>junit</groupId>
13
+            <artifactId>junit</artifactId>
14
+            <version>RELEASE</version>
15
+            <scope>test</scope>
16
+        </dependency>
17
+    </dependencies>
10 18
 
11 19
 
12 20
 </project>

+ 86
- 0
src/main/java/com/zipcodewilmington/productmanager/Inventory.java Visa fil

@@ -0,0 +1,86 @@
1
+package com.zipcodewilmington.productmanager;
2
+
3
+import java.util.ArrayList;
4
+
5
+public class Inventory{
6
+
7
+    ArrayList<Product> inventory = new ArrayList<>();
8
+
9
+    public void addItem(Product product){
10
+        inventory.add(product);
11
+    }
12
+
13
+    public void addItems(Product[] products){
14
+        for(Product product : products){
15
+            inventory.add(product);
16
+        }
17
+
18
+    }
19
+
20
+    public void remove(Product product){
21
+        inventory.remove(product);
22
+    }
23
+
24
+    public int sumOfItems(){
25
+        return inventory.size();
26
+    }
27
+
28
+    public String findItem(int id){
29
+
30
+        for(Product product: inventory){
31
+            if(product.getId() == id){
32
+                return product.getName();
33
+            }
34
+        }
35
+
36
+        return null;
37
+    }
38
+
39
+
40
+//    private String name;
41
+//    private int id;
42
+//    private int quantityOnHand;
43
+//
44
+//    public Inventory(String name, int id, int quantityOnHand){
45
+//        this.name = name;
46
+//        this.id = id;
47
+//        this.quantityOnHand = quantityOnHand;
48
+//    }
49
+//    Inventory item1 = new Inventory("Jacket", 1, 5);
50
+//    Inventory item2 = new Inventory("Hoodie", 2, 3);
51
+//    Inventory item3 = new Inventory("Pants", 3, 10);
52
+//
53
+//    public void setItem1(Inventory item1) {
54
+//        this.item1 = item1;
55
+//    }
56
+//
57
+//    public String getName() {
58
+//        return name;
59
+//    }
60
+//
61
+//    public void setName(String name) {
62
+//        this.name = name;
63
+//    }
64
+//
65
+//    public int getId() {
66
+//        return id;
67
+//    }
68
+//
69
+//    public void setId(int id) {
70
+//        this.id = id;
71
+//    }
72
+//
73
+//    public int getQuantityOnHand() {
74
+//        return quantityOnHand;
75
+//    }
76
+//
77
+//    public void setQuantityOnHand(int quantityOnHand) {
78
+//        this.quantityOnHand = quantityOnHand;
79
+//    }
80
+//
81
+//    public void updateQuantity(){
82
+//        quantityOnHand--;
83
+//    }
84
+
85
+
86
+}

+ 34
- 0
src/main/java/com/zipcodewilmington/productmanager/MainApplication.java Visa fil

@@ -1,7 +1,41 @@
1 1
 package com.zipcodewilmington.productmanager;
2 2
 
3
+import java.util.Scanner;
4
+
3 5
 /**
4 6
  * Created by leon on 1/10/18.
5 7
  */
6 8
 public class MainApplication {
9
+
10
+
11
+    public static void main(String[] args){
12
+
13
+        MainApplication app = new MainApplication();
14
+
15
+        Scanner scanner = new Scanner(System.in);
16
+
17
+        System.out.println("What piece of clothing are you interested in?");
18
+        //scanner.nextLine();
19
+
20
+        Product product = new Product("Shirt", 39.99, 4, 13);
21
+        Product product2 = new Product("Jacket", 29.99, 1, 53);
22
+        Product product3 = new Product("Shoes", 59.99, 3, 23);
23
+        Product product4 = new Product("Suit", 999.99, 5, 63);
24
+        Product product5 = new Product("Pants", 99.99, 2, 93);
25
+
26
+        Inventory inventory = new Inventory();
27
+
28
+        inventory.addItem(product);
29
+        inventory.addItem(product2);
30
+        inventory.addItem(product3);
31
+        inventory.addItem(product4);
32
+        inventory.addItem(product5);
33
+
34
+
35
+
36
+
37
+        System.out.println(product.getName());
38
+    }
39
+
40
+
7 41
 }

+ 53
- 0
src/main/java/com/zipcodewilmington/productmanager/Product.java Visa fil

@@ -4,4 +4,57 @@ package com.zipcodewilmington.productmanager;
4 4
  * Created by leon on 1/10/18.
5 5
  */
6 6
 public class Product {
7
+
8
+    private double price;
9
+
10
+    private int id;
11
+
12
+    private int quantityOnHand;
13
+
14
+    private String name;
15
+
16
+
17
+
18
+    public Product(String name, double price,int  id, int quantityOnHand){
19
+        this.price = price;
20
+        this.id = id;
21
+        this.quantityOnHand = quantityOnHand;
22
+        this.name = name;
23
+    }
24
+
25
+
26
+
27
+    public double getPrice() {
28
+
29
+        return price;
30
+    }
31
+
32
+    public void setPrice(double price) {
33
+        this.price = price;
34
+    }
35
+
36
+    public int getId() {
37
+
38
+        return id;
39
+    }
40
+
41
+    public void setId(int id) {
42
+        this.id = id;
43
+    }
44
+
45
+    public int getQuantityOnHand() {
46
+        return quantityOnHand;
47
+    }
48
+
49
+    public void setQuantityOnHand(int quantityOnHand) {
50
+        this.quantityOnHand = quantityOnHand;
51
+    }
52
+
53
+    public String getName() {
54
+        return name;
55
+    }
56
+
57
+    public void setName(String name) {
58
+        this.name = name;
59
+    }
7 60
 }

+ 72
- 0
src/test/java/com/zipcodewilmington/productmanager/ProductTest.java Visa fil

@@ -1,7 +1,79 @@
1 1
 package com.zipcodewilmington.productmanager;
2 2
 
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+
3 7
 /**
4 8
  * Created by leon on 1/10/18.
5 9
  */
6 10
 public class ProductTest {
11
+
12
+
13
+
14
+
15
+
16
+    @Test
17
+    public void setPriceTest(){
18
+        Product product = new Product("Jersey", 89.99, 1, 3);
19
+        product.setPrice(39.99);
20
+
21
+        Assert.assertEquals(39.99, product.getPrice(), 1);
22
+    }
23
+
24
+    @Test
25
+    public void getPriceTest(){
26
+        Product product = new Product("Jersey", 89.99, 1, 3);
27
+        product.getPrice();
28
+
29
+        Assert.assertEquals(89.99, product.getPrice(), 1);
30
+    }
31
+
32
+    @Test
33
+    public void getIdTest(){
34
+        Product product = new Product("Jersey", 89.99, 1, 3);
35
+        product.getId();
36
+
37
+        Assert.assertEquals(1, product.getId());
38
+    }
39
+
40
+    @Test
41
+    public void setIdTest(){
42
+        Product product = new Product("Jersey", 89.99, 1, 3);
43
+        product.setId(2);
44
+
45
+        Assert.assertEquals(2, product.getId());
46
+    }
47
+
48
+    @Test
49
+    public void getQuantityOnHand(){
50
+        Product product = new Product("Jersey", 89.99, 1, 3);
51
+        product.getQuantityOnHand();
52
+
53
+        Assert.assertEquals(3, product.getQuantityOnHand());
54
+    }
55
+
56
+    @Test
57
+    public void setQuantityOnHand(){
58
+        Product product = new Product("Jersey", 89.99, 1, 3);
59
+        product.setQuantityOnHand(12);
60
+
61
+        Assert.assertEquals(12, product.getQuantityOnHand());
62
+    }
63
+
64
+    @Test
65
+    public void getNameTest(){
66
+        Product product = new Product("Jersey", 89.99, 1, 3);
67
+        product.getName();
68
+
69
+        Assert.assertEquals("Jersey", product.getName());
70
+    }
71
+
72
+    @Test
73
+    public void setNameTest(){
74
+        Product product = new Product("Jersey", 89.99, 1, 3);
75
+        product.setName("Shirt");
76
+
77
+        Assert.assertEquals("Shirt", product.getName());
78
+    }
7 79
 }