diff --git a/.idea/Product-Inventory-Lab.iml b/.idea/Product-Inventory-Lab.iml
new file mode 100644
index 0000000..78b2cc5
--- /dev/null
+++ b/.idea/Product-Inventory-Lab.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 7a4bf35..4f08829 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -6,6 +6,7 @@
+
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 43c1af2..1708df8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,4 +22,42 @@
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.10.1
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.4.2
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.4.2
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter
+ RELEASE
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter
+ RELEASE
+ test
+
+
+ junit
+ junit
+ RELEASE
+ test
+
+
+
\ No newline at end of file
diff --git a/src/main/java/models/Coffee.java b/src/main/java/models/Coffee.java
new file mode 100644
index 0000000..2f9e170
--- /dev/null
+++ b/src/main/java/models/Coffee.java
@@ -0,0 +1,81 @@
+package models;
+
+
+public class Coffee {
+ private Integer unitId;
+ private Integer amountInStock;
+ private String brand;
+ private String flavor;
+ private Double price;
+ private Double weight;
+
+ public Coffee(Integer expectedUnitId, Integer expectedAmountInStock, String expectedBrand,
+ String expectedFlavor, Double expectedPrice, Double expectedWeight) {
+ this.unitId = expectedUnitId;
+ this.amountInStock = expectedAmountInStock;
+ this.brand = expectedBrand;
+ this.flavor = expectedFlavor;
+ this.price = expectedPrice;
+ this.weight = expectedWeight;
+ }
+
+ public Integer getUnitId() {
+ return unitId;
+ }
+
+ public void setUnitId(Integer unitId) {
+ this.unitId = unitId;
+ }
+
+ public Integer getAmountInStock() {
+ return amountInStock;
+ }
+
+ public void setAmountInStock(Integer amountInStock) {
+ this.amountInStock = amountInStock;
+ }
+
+ public java.lang.String getBrand() {
+ return brand;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ public java.lang.String getFlavor() {
+ return flavor;
+ }
+
+ public void setFlavor(String flavor) {
+ this.flavor = flavor;
+ }
+
+ public Double getPrice() {
+ return price;
+ }
+
+ public void setPrice(Double price) {
+ this.price = price;
+ }
+
+ public Double getWeight() {
+ return weight;
+ }
+
+ public void setWeight(Double weight) {
+ this.weight = weight;
+ }
+
+ @Override
+ public String toString() {
+ String printingInventory = "Unit ID: " + getUnitId();
+ printingInventory += "Amount in Stock: " + getAmountInStock();
+ printingInventory += "Brand Name: " + getBrand();
+ printingInventory += "Flavor Type: " + getFlavor();
+ printingInventory += "Retail Price: " + getPrice();
+ printingInventory += "Retail Weight: " + getWeight();
+
+ return printingInventory;
+ }
+}
diff --git a/src/main/java/models/Console.java b/src/main/java/models/Console.java
new file mode 100644
index 0000000..59717b8
--- /dev/null
+++ b/src/main/java/models/Console.java
@@ -0,0 +1,115 @@
+package models;
+
+import services.CoffeeService;
+import services.MugsService;
+
+import java.io.Writer;
+import java.lang.invoke.SwitchPoint;
+import java.sql.SQLOutput;
+import java.util.Scanner;
+
+import static services.CoffeeService.inventory;
+import static services.CoffeeService.nextUnitId;
+
+public class Console {
+ private static Inventory inventory = new Inventory();
+
+
+ public static void printWelcome() {
+ System.out.println("Welcome to Mugs N' Cof");
+ }
+
+ public static void initializeSampleInventory() {
+ CoffeeService coffeeService = inventory.getCoffeeService();
+ MugsService mugsService = inventory.getMugsService();
+
+ coffeeService.create(100, 4000, "Folgers",
+ "Dark Roast", 9.99, 16.0);
+ coffeeService.create(69, 3500, "Maxwell",
+ "Light Roast", 14.99, 18.0);
+ coffeeService.create(4951, 30, "Starbucks",
+ "Medium Roast", 12.99, 24.00);
+ }
+
+ public static void entryMenu () {
+ Scanner scanner = new Scanner(System.in);
+ print("1. Inventory");
+ print("2. Update");
+ print("3. Delete");
+ print("4. Exit");
+ int userInput = scanner.nextInt();
+ switch (userInput) {
+ case 1 :
+ inventoryMenu();
+ break;
+ case 2 :
+ updateMenu();
+ break;
+ case 3 :
+ deleteMenu();
+ break;
+ case 4 :
+ default:
+ print("See ya soon, buckaroon");
+ }
+
+ }
+
+ public static void inventoryMenu() {
+ Scanner scanner = new Scanner(System.in);
+ print("What inventory would you like to view");
+ print("1. Coffee");
+ print("2. Mugs");
+ int userInput = scanner.nextInt();
+ switch (userInput) {
+ case 1 :
+ coffeeInventory();
+ entryMenu();
+ break;
+ case 2 :
+ // mugsInventory();
+ break;
+ default:
+ }
+
+ }
+
+ public static void coffeeInventory () {
+ Integer option = 1;
+
+ Coffee[] coffeeInventory = inventory.getCoffeeService().findAll();
+ for (Coffee coffee : coffeeInventory) {
+ print(option++ + coffee.toString());
+ }
+ }
+
+ public static void updateMenu () {
+ coffeeInventory();
+ Scanner scanner = new Scanner(System.in);
+ Coffee[] coffeeInventory = inventory.getCoffeeService().findAll();
+ int userInput = scanner.nextInt();
+ Coffee coffee = coffeeInventory[userInput - 1];
+ print("Enter new number for amount");
+ scanner.nextLine();
+ userInput = scanner.nextInt();
+ coffee.setAmountInStock(userInput);
+ entryMenu();
+ }
+
+ public static void deleteMenu () {
+ coffeeInventory();
+ print("Enter numbered item for deletion");
+ Scanner scanner = new Scanner(System.in);
+ Coffee[] coffeeInventory = inventory.getCoffeeService().findAll();
+ int userInput = scanner.nextInt();
+ Coffee coffee = coffeeInventory[userInput - 1];
+ inventory.getCoffeeService().delete(coffee.getUnitId());
+ entryMenu();
+ }
+
+
+ public static void print(String input) {
+ System.out.println(input);
+ }
+
+}
diff --git a/src/main/java/models/Inventory.java b/src/main/java/models/Inventory.java
new file mode 100644
index 0000000..8c94795
--- /dev/null
+++ b/src/main/java/models/Inventory.java
@@ -0,0 +1,35 @@
+package models;
+
+import services.CoffeeService;
+import services.MugsService;
+
+import java.util.Scanner;
+
+public class Inventory {
+ private CoffeeService coffeeService = new CoffeeService();
+ private MugsService mugsService = new MugsService();
+
+ public CoffeeService getCoffeeService() {
+ return this.coffeeService;
+ }
+
+ public MugsService getMugsService() {
+ return this.mugsService;
+ }
+
+ public Integer coffeeInStock() {
+ Coffee[] allCoffee = this.coffeeService.findAll();
+ Integer count = 0;
+
+ for(Coffee index: allCoffee) {
+ count += index.getAmountInStock();
+ }
+ return count;
+ }
+
+ public Integer specificOrder() {
+ // return this.coffeeService.findCoffee();
+ return null;
+ }
+
+}
diff --git a/src/main/java/models/MainApplication.java b/src/main/java/models/MainApplication.java
new file mode 100644
index 0000000..ed62a34
--- /dev/null
+++ b/src/main/java/models/MainApplication.java
@@ -0,0 +1,23 @@
+package models;
+
+import services.CoffeeService;
+
+import java.io.IOException;
+
+public class MainApplication {
+
+ private CoffeeService coffeeService = new CoffeeService();
+
+ public static void main(String[] args) throws IOException {
+ MainApplication mainApp = new MainApplication();
+ mainApp.init();
+ }
+
+ public void init() throws IOException {
+ Console.printWelcome();
+ Console.initializeSampleInventory();
+ //CoffeeService.loadData();
+ CoffeeService.fileSaver();
+ Console.entryMenu();
+ }
+}
diff --git a/src/main/java/models/Mugs.java b/src/main/java/models/Mugs.java
new file mode 100644
index 0000000..4ed2a5a
--- /dev/null
+++ b/src/main/java/models/Mugs.java
@@ -0,0 +1,4 @@
+package models;
+
+public class Mugs {
+}
diff --git a/src/main/java/services/CoffeeService.java b/src/main/java/services/CoffeeService.java
new file mode 100644
index 0000000..a46b54a
--- /dev/null
+++ b/src/main/java/services/CoffeeService.java
@@ -0,0 +1,111 @@
+package services;
+
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+
+import models.Coffee;
+import utils.CSVUtils;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class CoffeeService {
+
+ public static Integer nextUnitId = 1;
+ public static ArrayList inventory = new ArrayList<>();
+
+ public Coffee create(Integer unitId, Integer amountInStock, String brand, String flavor, Double price, Double weight) {
+
+ Coffee createdCoffee = new Coffee(unitId++, amountInStock, brand, flavor, price, weight);
+
+ inventory.add(createdCoffee);
+
+ return createdCoffee;
+ }
+
+ public Coffee findCoffee(Integer unitId) {
+ return inventory.get(unitId);
+ }
+ public Coffee[] findAll() {
+ return inventory.toArray(new Coffee[0]);
+ }
+ public boolean delete(Integer unitId) {
+ for(Coffee element: inventory){
+ if(element.getUnitId() == unitId){
+ inventory.remove(element);
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public static void fileSaver () throws IOException {
+
+
+ String csvFile = "/Users/nick/Desktop/Coffee.csv";
+ FileWriter writer = new FileWriter(csvFile); //(1)
+
+ CSVUtils.writeLine(writer, new ArrayList(Arrays.asList(String.valueOf(nextUnitId)))); // (2)
+
+ for (Coffee s : inventory) {
+ List list = new ArrayList<>(); // (3)
+ list.add(String.valueOf(s.getUnitId()));
+ list.add(String.valueOf(s.getAmountInStock()));
+ list.add(s.getBrand());
+ list.add(s.getFlavor());
+ list.add(String.valueOf(s.getPrice()));
+ list.add(String.valueOf(s.getWeight()));
+
+ CSVUtils.writeLine(writer, list); // (4)
+ }
+
+// (5)
+ writer.flush(); // nice
+ writer.close();
+
+ }
+
+
+ public static void loadData() {
+
+ String csvFile = "/Users/nick/Desktop/Coffee.csv";
+ String line = "";
+ String csvSplitBy = ",";
+
+
+
+ try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {
+ nextUnitId = Integer.parseInt(br.readLine());
+
+ while ((line = br.readLine()) != null) {
+
+ String[] coffee = line.split(csvSplitBy);
+ int nextUnitId = Integer.valueOf(coffee[0]);
+ int amountInStock = Integer.valueOf(coffee[1]);
+ String brand = coffee[2];
+ String flavor = coffee[3];
+ Double price = Double.valueOf(coffee[4]);
+ Double weight = Double.valueOf(coffee[5]);
+
+ inventory.add(new Coffee(nextUnitId, amountInStock, brand, flavor, price, weight));
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ public static void writingJSON () throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ ObjectWriter writer = mapper.writer(new DefaultPrettyPrinter());
+ writer.writeValue(new File("sneaker.json"), inventory);
+ }
+ public static void readingJSON() throws IOException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ inventory = objectMapper.readValue(new File("sneaker.json"), new TypeReference>(){});
+ }
+}
diff --git a/src/main/java/services/MugsService.java b/src/main/java/services/MugsService.java
new file mode 100644
index 0000000..243a11d
--- /dev/null
+++ b/src/main/java/services/MugsService.java
@@ -0,0 +1,4 @@
+package services;
+
+public class MugsService {
+}
diff --git a/src/main/java/utils/CSVUtils.java b/src/main/java/utils/CSVUtils.java
new file mode 100644
index 0000000..cc309f6
--- /dev/null
+++ b/src/main/java/utils/CSVUtils.java
@@ -0,0 +1,30 @@
+package utils;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+
+public class CSVUtils {
+ private static final char DEFAULT_SEPARATOR = ','; // (1)
+
+ // (2)
+ public static void writeLine(Writer w, List values) throws IOException {
+ boolean first = true;
+
+ StringBuilder sb = new StringBuilder();
+
+ // (3)
+ for (String value : values) {
+ if (!first) {
+ sb.append(DEFAULT_SEPARATOR);
+ }
+ sb.append(value);
+ first = false;
+ }
+ sb.append("\n");
+
+ w.append(sb.toString()); // (4)
+ }
+}
+
+
diff --git a/src/test/java/models/CoffeeTest.java b/src/test/java/models/CoffeeTest.java
new file mode 100644
index 0000000..ec5efd2
--- /dev/null
+++ b/src/test/java/models/CoffeeTest.java
@@ -0,0 +1,161 @@
+package models;
+
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class CoffeeTest {
+
+
+ @Test
+ public void constructorTest () {
+ //Given
+ Integer expectedUnitId = 203;
+ Integer expectedAmountInStock = 1000;
+ String expectedBrand = "Maxwell";
+ String expectedFlavor = "Dark Roast";
+ Double expectedPrice = 16.00;
+ Double expectedWeight = 12.0;
+ //When
+ Coffee testCoffee = new Coffee(expectedUnitId, expectedAmountInStock, expectedBrand, expectedFlavor
+ , expectedPrice, expectedWeight);
+ }
+
+ @Test
+ public void getUnitIdTest () {
+ // given
+ Integer expectedUnitId = 100;
+
+ // when
+ Coffee coffee = new Coffee(expectedUnitId, null, null , null
+ , null , null );
+ coffee.setUnitId(expectedUnitId);
+ Integer actual = coffee.getUnitId();
+
+ // then
+ Assert.assertEquals(expectedUnitId, actual);
+ }
+
+ @Test
+ public void setUnitIdTest () {
+ // given
+ Integer expectedUnitId = 100;
+
+ // when
+ Coffee coffee = new Coffee(expectedUnitId, null, null , null
+ , null , null );
+ coffee.setUnitId(expectedUnitId);
+ Integer actual = coffee.getUnitId();
+
+ // then
+ Assert.assertEquals(expectedUnitId, actual);
+ }
+
+ @Test
+ public void getAmountInStock () {
+ // given
+ Integer expectedAmount = 1000;
+ // when
+ Coffee coffee = new Coffee(null, expectedAmount, null , null
+ , null , null );
+ coffee.setAmountInStock(expectedAmount);
+ Integer actual = coffee.getAmountInStock();
+ // then
+ Assert.assertEquals(expectedAmount, actual);
+ }
+
+ @Test
+ public void setAmountInStock () {
+ // given
+ Integer expectedAmount = 1000;
+ // when
+ Coffee coffee = new Coffee(null, expectedAmount, null , null
+ , null , null );
+ coffee.setAmountInStock(expectedAmount);
+ Integer actual = coffee.getAmountInStock();
+ // then
+ Assert.assertEquals(expectedAmount, actual);
+ }
+
+ @Test
+ public void getBrandTest () {
+ String expectedBrand = "Folgers";
+ Coffee coffee = new Coffee(null, null, expectedBrand , null
+ , null , null );
+ coffee.setBrand(expectedBrand);
+ String actual = coffee.getBrand();
+ Assert.assertEquals(expectedBrand, actual);
+ }
+
+ @Test
+ public void setBrandTest () {
+ String expectedBrand = "Folgers";
+ Coffee coffee = new Coffee(null, null, expectedBrand , null
+ , null , null );
+ coffee.setBrand(expectedBrand);
+ String actual = coffee.getBrand();
+ Assert.assertEquals(expectedBrand, actual);
+ }
+
+ @Test
+ public void getFlavorTest () {
+ String expectedFlavor = "Dark Roast";
+ Coffee coffee = new Coffee(null, null, null, expectedFlavor
+ , null , null );
+ coffee.setFlavor(expectedFlavor);
+ String actual = coffee.getFlavor();
+ Assert.assertEquals(expectedFlavor, actual);
+ }
+
+ @Test
+ public void setFlavorTest () {
+ String expectedFlavor = "Dark Roast";
+ Coffee coffee = new Coffee(null, null, null, expectedFlavor
+ , null , null );
+ coffee.setFlavor(expectedFlavor);
+ String actual = coffee.getFlavor();
+ Assert.assertEquals(expectedFlavor, actual);
+ }
+
+ @Test
+ public void setPriceTest () {
+ Double expectedPrice = 10.00;
+ Coffee coffee = new Coffee(null, null, null, null
+ , expectedPrice , null );
+ coffee.setPrice(expectedPrice);
+ Double actual = coffee.getPrice();
+ Assert.assertEquals(expectedPrice, actual);
+ }
+
+ @Test
+ public void getPriceTest () {
+ Double expectedPrice = 10.00;
+ Coffee coffee = new Coffee(null, null, null, null
+ , expectedPrice , null );
+ coffee.setPrice(expectedPrice);
+ Double actual = coffee.getPrice();
+ Assert.assertEquals(expectedPrice, actual);
+ }
+
+ @Test
+ public void setWeightTest () {
+ Double expectedWeight = 16.0;
+ Coffee coffee = new Coffee(null, null, null, null
+ , null , expectedWeight );
+ coffee.setWeight(expectedWeight);
+ Double actual = coffee.getWeight();
+ Assert.assertEquals(expectedWeight, actual);
+ }
+
+ @Test
+ public void getWeightTest () {
+ Double expectedWeight = 16.0;
+ Coffee coffee = new Coffee(null, null, null, null
+ , null , expectedWeight );
+ coffee.setWeight(expectedWeight);
+ Double actual = coffee.getWeight();
+ Assert.assertEquals(expectedWeight, actual);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/models/MugsTest.java b/src/test/java/models/MugsTest.java
new file mode 100644
index 0000000..fc55c1c
--- /dev/null
+++ b/src/test/java/models/MugsTest.java
@@ -0,0 +1,8 @@
+package models;
+
+
+import org.junit.Test;
+
+public class MugsTest {
+
+}
\ No newline at end of file
diff --git a/src/test/java/services/CoffeeServiceTest.java b/src/test/java/services/CoffeeServiceTest.java
new file mode 100644
index 0000000..ec6fc2d
--- /dev/null
+++ b/src/test/java/services/CoffeeServiceTest.java
@@ -0,0 +1,36 @@
+package services;
+
+
+import models.Coffee;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CoffeeServiceTest {
+ @Test
+ public void serviceUnitIdTest () {
+ Integer expectedUnitId = 4;
+ Integer expectedAmountInStock = 499;
+ String expectedBrand = "Maxwell";
+ String expectedFlavor = "Light Roast";
+ Double expectedPrice = 19.99;
+ Double expectedWeight = 16.0;
+
+ CoffeeService coffeeService = new CoffeeService();
+ Coffee testCoffee = coffeeService.create(expectedUnitId, expectedAmountInStock, expectedBrand, expectedFlavor
+ , expectedPrice, expectedWeight);
+
+ Integer actualUnitId = testCoffee.getUnitId();
+ Integer actualAmountInStock = testCoffee.getAmountInStock();
+ String actualBrand = testCoffee.getBrand();
+ String actualFlavor = testCoffee.getFlavor();
+ Double actualPrice = testCoffee.getPrice();
+ Double actualWeight = testCoffee.getWeight();
+
+ Assert.assertEquals(Integer.class.getName(), new Integer(actualUnitId).getClass().getName());
+ Assert.assertEquals(expectedAmountInStock, actualAmountInStock);
+ Assert.assertEquals(expectedBrand, actualBrand);
+ Assert.assertEquals(expectedFlavor, actualFlavor);
+ Assert.assertEquals(expectedPrice, actualPrice);
+ Assert.assertEquals(expectedWeight, actualWeight);
+ }
+}
diff --git a/src/test/java/services/MugsServiceTest.java b/src/test/java/services/MugsServiceTest.java
new file mode 100644
index 0000000..09c877e
--- /dev/null
+++ b/src/test/java/services/MugsServiceTest.java
@@ -0,0 +1,7 @@
+package services;
+
+import org.junit.Test;
+
+public class MugsServiceTest {
+
+}