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/.idea/misc.xml b/.idea/misc.xml
index 4b661a5..5d540cf 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -11,4 +11,7 @@
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 43c1af2..c3fbd83 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,5 +21,19 @@
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.4.2
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.4.2
+ test
+
+
\ No newline at end of file
diff --git a/src/main/java/io/Console.java b/src/main/java/io/Console.java
new file mode 100644
index 0000000..3bb0b7f
--- /dev/null
+++ b/src/main/java/io/Console.java
@@ -0,0 +1,253 @@
+package io;
+
+import models.Sneaker;
+import models.Whiskey;
+import services.SneakerService;
+import services.WhiskeyService;
+
+import java.util.Scanner;
+
+public class Console {
+
+ SneakerService sneakerService = new SneakerService();
+ WhiskeyService whiskeyService = new WhiskeyService();
+
+ public static void main(String[] args) {
+ Console console = new Console();
+ console.loadInventory();
+ console.printWelcome();
+ console.printProductMenu();
+ }
+
+ public void printWelcome() {
+ System.out.println(
+ "**************************************************\n" +
+ "*** Welcome and Bienvenue ***\n" +
+ "*** to ***\n" +
+ "*** ZipCo Inventory Manager ***\n" +
+ "**************************************************\n");
+ }
+
+ public void printProductMenu() {
+ int selection = -1;
+ while(selection != 0) {
+ selection = readInt("Please select a product:\n" +
+ "1. Sneakers\n" +
+ "2. Whiskey\n" +
+ "0. Exit");
+ switch (selection) {
+ case 1:
+ sneakerMenuSelect();
+ break;
+ case 2:
+ whiskeyMenuSelect();
+ break;
+ case 0:
+ System.out.println("Goodbye!");
+ System.exit(0);
+ break;
+ }
+ }
+ }
+
+ public void loadInventory() {
+ sneakerService.loadInventory();
+ whiskeyService.loadInventory();
+ }
+
+ public void printWhiskeyMenu() {
+ System.out.println("Please select an option:\n" +
+ "1. View all whiskies\n" +
+ "2. Add a new whiskey\n" +
+ "3. Find a whiskey\n" +
+ "4. Update a whiskey\n" +
+ "5. Delete a whiskey\n" +
+ "6. Previous menu\n" +
+ "0. Exit");
+ }
+
+ public void printWhiskies() {
+ Whiskey[] whiskeys = whiskeyService.findAll();
+ for (Whiskey w : whiskeys) {
+ System.out.println(w);
+ }
+ }
+
+ public void whiskeyMenuSelect() {
+ Console console = new Console();
+ int option = -1;
+ while(option != 0) {
+ console.printWhiskeyMenu();
+ option = readInt("Please select an option: ");
+ switch (option) {
+ case 1:
+ printWhiskies();
+ break;
+ case 2:
+ String brand = readString("Enter the brand: ");
+ String description = readString("Enter the description: ");
+ Double size = readDouble("Enter the size: ");
+ Double price = readDouble("Enter the price: ");
+ Integer quantity = readInt("Enter the quantity: ");
+ Whiskey whiskey = new Whiskey(brand, description, size, price, quantity);
+ whiskeyService.create(whiskey);
+ break;
+ case 3:
+ int id = readInt("Enter the id: ");
+ whiskey = whiskeyService.find(id);
+ if (whiskey != null) {
+ System.out.println(whiskey);
+ } else {
+ System.out.println("Whiskey not found");
+ }
+ break;
+ case 4:
+ id = readInt("Enter the id: ");
+ whiskey = whiskeyService.find(id);
+ if (whiskey != null) {
+ brand = readString("Enter the brand: ");
+ description = readString("Enter the description: ");
+ size = readDouble("Enter the size: ");
+ price = readDouble("Enter the price: ");
+ quantity = readInt("Enter the quantity: ");
+ whiskey.setBrand(brand);
+ whiskey.setDescription(description);
+ whiskey.setSize(size);
+ whiskey.setPrice(price);
+ whiskey.setQuantity(quantity);
+ whiskeyService.update(whiskey, id);
+ } else {
+ System.out.println("Whiskey not found");
+ }
+ break;
+ case 5:
+ id = readInt("Enter the id: ");
+ whiskeyService.delete(id);
+ break;
+ case 6:
+ console.printProductMenu();
+ break;
+ case 0:
+ whiskeyService.writeToFile();
+ System.out.println("Goodbye!");
+ System.exit(0);
+ break;
+ }
+ }
+ }
+
+ public void printSneakerMenu() {
+ System.out.println(
+ "Please select an option:\n" +
+ "1. View all sneakers\n" +
+ "2. Add a new sneaker\n" +
+ "3. Find a sneaker\n" +
+ "4. Update a sneaker\n" +
+ "5. Delete a sneaker\n" +
+ "6. Previous menu\n" +
+ "0. Exit");
+ }
+
+ public void printSneakers() {
+ Sneaker[] sneakers = sneakerService.findAll();
+ for (Sneaker sneaker : sneakers) {
+ System.out.println(sneaker);
+ }
+ }
+
+ public void sneakerMenuSelect() {
+ Console console = new Console();
+ int option = -1;
+ while (option != 0) {
+ console.printSneakerMenu();
+ option = readInt("Please select an option: ");
+ switch (option) {
+ case 1:
+ printSneakers();
+ break;
+ case 2:
+ String name = readString("Enter the sneaker name");
+ String brand = readString("Enter the sneaker brand");
+ String color = readString("Enter the sneaker color");
+ String sport = readString("Enter the sneaker sport");
+ Double size = readDouble("Enter the sneaker size");
+ Double price = readDouble("Enter the sneaker price");
+ Integer quantity = readInt("Enter the sneaker quantity");
+ Sneaker sneaker = new Sneaker(name, brand, color, sport, size, price, quantity);
+ sneakerService.create(sneaker);
+ break;
+ case 3:
+ Integer id = readInt("Enter the sneaker id");
+ Sneaker foundSneaker = sneakerService.find(id);
+ if (foundSneaker != null) {
+ System.out.println(foundSneaker);
+ } else {
+ System.out.println("Sneaker not found");
+ }
+ break;
+ case 4:
+ id = readInt("Enter the sneaker id");
+ Sneaker foundSneaker2 = sneakerService.find(id);
+ if (foundSneaker2 != null) {
+ String name2 = readString("Enter the sneaker name");
+ String brand2 = readString("Enter the sneaker brand");
+ String color2 = readString("Enter the sneaker color");
+ String sport2 = readString("Enter the sneaker sport");
+ Double size2 = readDouble("Enter the sneaker size");
+ Double price2 = readDouble("Enter the sneaker price");
+ Integer quantity2 = readInt("Enter the sneaker quantity");
+ Sneaker sneaker2 = new Sneaker(name2, brand2, color2, sport2, size2, price2, quantity2);
+ sneakerService.update(sneaker2, id);
+ } else {
+ System.out.println("Sneaker not found");
+ }
+ break;
+ case 5:
+ id = readInt("Enter the sneaker id");
+ sneakerService.delete(id);
+ break;
+ case 6:
+ printProductMenu();
+ break;
+ case 0:
+ sneakerService.writeToFile();
+ System.out.println("Goodbye!");
+ System.exit(0);
+ break;
+ }
+ }
+ }
+
+ private Integer readInt(String s) {
+ System.out.println(s);
+ Scanner scanner = new Scanner(System.in);
+ if(scanner.hasNextInt()) {
+ return scanner.nextInt();
+ } else {
+ System.out.println("Invalid input");
+ return readInt(s);
+ }
+ }
+
+ private String readString(String s) {
+ System.out.println(s);
+ Scanner scanner = new Scanner(System.in);
+ if(scanner.hasNext()) {
+ return scanner.next();
+ } else {
+ System.out.println("Invalid input");
+ return readString(s);
+ }
+ }
+
+ private Double readDouble(String s) {
+ System.out.println(s);
+ Scanner scanner = new Scanner(System.in);
+ if(scanner.hasNextDouble()) {
+ return scanner.nextDouble();
+ } else {
+ System.out.println("Invalid input");
+ return readDouble(s);
+ }
+ }
+}
diff --git a/src/main/java/models/Sneaker.java b/src/main/java/models/Sneaker.java
new file mode 100644
index 0000000..a269a02
--- /dev/null
+++ b/src/main/java/models/Sneaker.java
@@ -0,0 +1,104 @@
+package models;
+
+public class Sneaker {
+ private Integer id;
+ private String name;
+ private String brand;
+ private String color;
+ private String sport;
+ private Double size;
+ private Double price;
+ private Integer quantity;
+
+ public Sneaker() {
+ }
+
+ public Sneaker(String name, String brand,
+ String color, String sport, Double size,
+ Double price, Integer quantity) {
+ this.name = name;
+ this.brand = brand;
+ this.color = color;
+ this.sport = sport;
+ this.size = size;
+ this.price = price;
+ this.quantity = quantity;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ public void setColor(String color) {
+ this.color = color;
+ }
+
+ public void setSport(String sport) {
+ this.sport = sport;
+ }
+
+ public void setSize(Double size) {
+ this.size = size;
+ }
+
+ public void setPrice(Double price) {
+ this.price = price;
+ }
+
+ public void setQuantity(Integer quantity) {
+ this.quantity = quantity;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getBrand() {
+ return brand;
+ }
+
+ public String getColor() {
+ return color;
+ }
+
+ public String getSport() {
+ return sport;
+ }
+
+ public Double getSize() {
+ return size;
+ }
+
+ public Double getPrice() {
+ return price;
+ }
+
+ public Integer getQuantity() {
+ return quantity;
+ }
+
+ public String toString() {
+ return "Sneaker{" +
+ "id=" + id +
+ ", name='" + name + '\'' +
+ ", brand='" + brand + '\'' +
+ ", color='" + color + '\'' +
+ ", sport='" + sport + '\'' +
+ ", size=" + size +
+ ", price=" + price +
+ ", quantity=" + quantity +
+ '}';
+ }
+}
diff --git a/src/main/java/models/Whiskey.java b/src/main/java/models/Whiskey.java
new file mode 100644
index 0000000..fa29e36
--- /dev/null
+++ b/src/main/java/models/Whiskey.java
@@ -0,0 +1,81 @@
+package models;
+
+public class Whiskey {
+ private Integer id;
+ private String brand;
+ private String description;
+ private Double size;
+ private Double price;
+ private Integer quantity;
+
+ public Whiskey() {
+ }
+
+ public Whiskey(String brand, String description, Double size, Double price, Integer quantity) {
+ this.brand = brand;
+ this.description = description;
+ this.size = size;
+ this.price = price;
+ this.quantity = quantity;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setSize(Double size) {
+ this.size = size;
+ }
+
+ public void setPrice(Double price) {
+ this.price = price;
+ }
+
+ public void setQuantity(Integer quantity) {
+ this.quantity = quantity;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public String getBrand() {
+ return brand;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public Double getSize() {
+ return size;
+ }
+
+ public Double getPrice() {
+ return price;
+ }
+
+ public Integer getQuantity() {
+ return quantity;
+ }
+
+ @Override
+ public String toString() {
+ return "Whiskey{" +
+ "id=" + id +
+ ", brand='" + brand + '\'' +
+ ", description='" + description + '\'' +
+ ", size=" + size +
+ ", price=" + price +
+ ", quantity=" + quantity +
+ '}';
+ }
+}
diff --git a/src/main/java/services/SneakerService.java b/src/main/java/services/SneakerService.java
new file mode 100644
index 0000000..5cb8baf
--- /dev/null
+++ b/src/main/java/services/SneakerService.java
@@ -0,0 +1,122 @@
+package services;
+
+import jdk.nashorn.internal.runtime.regexp.joni.Regex;
+import models.Sneaker;
+import utils.CSVUtils;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class SneakerService {
+
+ protected List inventory;
+ protected Sneaker sneaker;
+
+
+ public SneakerService() {
+ inventory = new ArrayList<>();
+ sneaker = new Sneaker();
+ }
+
+ public Sneaker create(Sneaker sneaker) {
+ sneaker.setId(inventory.size() + 1);
+ inventory.add(sneaker);
+ return sneaker;
+ }
+
+ public Sneaker find(Integer id) {
+ for (Sneaker sneaker : inventory) {
+ if (sneaker.getId().equals(id)) {
+ return sneaker;
+ }
+ }
+ return null;
+ }
+
+ public Sneaker[] findAll() {
+ Sneaker[] sneakers = new Sneaker[inventory.size()];
+ for (int i = 0; i < inventory.size(); i++) {
+ sneakers[i] = inventory.get(i);
+ }
+ return sneakers;
+ }
+
+ public Sneaker update(Sneaker sneaker, Integer id) {
+ for (Sneaker s : inventory) {
+ if (s.getId().equals(id)) {
+ s.setName(sneaker.getName());
+ s.setBrand(sneaker.getBrand());
+ s.setColor(sneaker.getColor());
+ s.setSport(sneaker.getSport());
+ s.setSize(sneaker.getSize());
+ s.setPrice(sneaker.getPrice());
+ s.setQuantity(sneaker.getQuantity());
+ return s;
+ }
+ }
+ return null;
+ }
+
+ public boolean delete(Integer id) {
+ for (Sneaker s : inventory) {
+ if (s.getId().equals(id)) {
+ inventory.remove(s);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void writeToFile() {
+ try {
+ String csvFile = "src/main/resources/sneakers.csv";
+ FileWriter writer = new FileWriter(csvFile);
+ List