Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions instructions/section-01.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ In this section we start with an empty Java project and start to setup our envir
* Import a testing framework to support Test Driven Development(TDD)
* Creating classes stubs for our products


## Part 1 - Repository

1. Log into github.com
Expand Down
20 changes: 19 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,23 @@
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
26 changes: 26 additions & 0 deletions src/main/java/io/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io;
import services.SneakerService;

import java.io.IOException;

public class App {
public static void main(String... args) throws IOException {

App application = new App();
Inventory.putSomeItemsInInventory();
application.init();

// Creating a new CSV file
//SneakerService.makeCSVfile();

}
private void init() throws IOException {
Console.printWelcome();
Console.printOptions();
Console.options();
//SneakerService.makeCSVfile();
SneakerService.loadData();

}

}
82 changes: 82 additions & 0 deletions src/main/java/io/Console.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package io;

import java.util.Scanner;

public class Console {

public static void printWelcome(){
System.out.println("" +
"**************************************************" + "\n" +
"*** Welcome and Bienvenue ***" + "\n" +
"*** to ***" + "\n" +
"*** Nathan's Inventory Manager ***" + "\n" +
"**************************************************");
}
//Prints out the options for app
public static void printOptions() {
System.out.println("" +
"*****************************************" + "\n" +
"*** 1. Create new product ***" + "\n" +
"*** 2. View current inventory ***" + "\n" +
"*** 3. Update product ***" + "\n" +
"*** 4. View product reports ***" + "\n" +
"*** 5. Exit ***" + "\n" +
"*****************************************");
}

public static void print(String output, Object...args){
System.out.printf(output, args);
}

public static void println(String output, Object...args){
print(output + "\n" + args);
}

public static String getStringInput(String prompt) {
Scanner scanner = new Scanner(System.in);
println(prompt);
return scanner.nextLine();
}

public static Integer getIntegerInput(String prompt) {
Scanner scanner = new Scanner(System.in);
println(prompt);
return Integer.parseInt(scanner.nextLine());
}

public static Float getFloatInput(String prompt) {
Scanner scanner = new Scanner(System.in);
println(String.valueOf(prompt));
return Float.parseFloat((scanner.nextLine()));
}

public static void options() {
boolean exitNow = false;
while(exitNow == false){
Integer option = Console.getIntegerInput("Type number to choose option:");
switch (option) {
case 1:
Inventory.makeNewProduct();
break;
case 2:
//View current inventory
Inventory.viewInventory();
break;
case 3:
//Update product - delete product
Inventory.removeProduct();
break;
case 4:
//View product reports
Inventory.viewProduct();
break;
case 5:
//Exit
exitNow = true;
break;
}
}
}


}
95 changes: 95 additions & 0 deletions src/main/java/io/Inventory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package io;

import models.Shirt;
import models.Sneaker;
import services.CSVUtils;
import services.ShirtService;
import services.SneakerService;

import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

public class Inventory {
static SneakerService sneakerService = new SneakerService();
static ShirtService shirtService = new ShirtService();

static void putSomeItemsInInventory() {
sneakerService.create("NitroBalance", "Nike", "Running", 8, 60.00f);
sneakerService.create("RainbowFeet", "Adidas", "Soccer", 7, 55.00f);
sneakerService.create("BubbleGum", "Puma", "Dance", 6, 70.00f);
shirtService.create("Vneck", "Jcrew", "Cotton", 25, 20.00f);
shirtService.create("Button-Down", "FruitDeLoom", "Cotton", 50, 10.00f);
shirtService.create("Sweater", "Nautica", "Wool", 15, 45.00f);
}


static void viewInventory(){
ArrayList<String> wholeInventory = new ArrayList<>();
for (Shirt shirt: shirtService.findAll()) {
wholeInventory.add(shirt.getShirtType());
}
for (Sneaker sneaker: sneakerService.findAll()) {
wholeInventory.add(sneaker.getName());
}
String readOut = wholeInventory.toString();
Console.println("The current inventory has: " + readOut.substring(1, readOut.length()-1 ));
}

static void viewProduct() {
String productType = Console.getStringInput("Shirts or Sneakers?");
switch (productType.toLowerCase(Locale.ROOT)) {
case "shirts":
Integer viewThisShirt = Console.getIntegerInput("Enter item ID to view");
Console.println("" + shirtService.find(viewThisShirt).toString());
break;
case "sneaker":
Integer viewThisSneaker = Console.getIntegerInput("Enter item ID to view");
Console.println("" + sneakerService.find(viewThisSneaker).toString());
break;
}
}

static void removeProduct() {
String productType = Console.getStringInput("Shirts or Sneakers?");
switch (productType.toLowerCase(Locale.ROOT)){
case "shirts":
Integer deleteThisShirt = Console.getIntegerInput("Enter item ID to delete");
shirtService.delete(deleteThisShirt);
break;
case "sneakers":
Integer deleteThisSneaker = Console.getIntegerInput("Enter item ID to delete");
sneakerService.delete(deleteThisSneaker);
break;
}
}

public static void makeNewProduct(){
String productType = Console.getStringInput("Choose shirt or sneaker").toLowerCase(Locale.ROOT);
switch(productType) {
case "shirt":
//Male new shirt
String shirtType = Console.getStringInput("Enter shirt type:");
String shirtBrand = Console.getStringInput("Enter shirt brand:");
String shirtMaterial = Console.getStringInput("Enter shirt material:");
int shirtQuantity = Console.getIntegerInput("Enter quantity:");
float shirtPrice = Console.getFloatInput("Enter price");
shirtService.create(shirtType, shirtBrand, shirtMaterial, shirtQuantity, shirtPrice);

break;
case "sneaker":
//Make new sneaker
String sneakerName = Console.getStringInput("Enter sneaker name:");
String sneakerBrand = Console.getStringInput("Enter sneaker brand:");
String sneakerSport = Console.getStringInput("Enter sneaker sport:");
int sneakerSize = Console.getIntegerInput("Enter sneaker size:");
int sneakerQty = Console.getIntegerInput("Enter quantity:");
float sneakerPrice = Console.getFloatInput("Enter price:");
sneakerService.create(sneakerName, sneakerBrand, sneakerSport, sneakerQty, sneakerPrice);
break;
}
}

}
71 changes: 71 additions & 0 deletions src/main/java/models/Shirt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package models;

public class Shirt {
private int id;
private String shirtType;
private String brand;
private String material;
private int quantity;
private float price;

public Shirt(){
}

public Shirt(int id, String shirtType, String brand, String material, int quantity, float price) {
this.id = id;
this.shirtType = shirtType;
this.brand = brand;
this.material = material;
this.quantity = quantity;
this.price = price;
}

public void setShirtType(String type) {
this.shirtType = type;
}

public String getShirtType() {
return this.shirtType;
}

public void setBrand(String brand) {
this.brand = brand;
}

public String getBrand() {
return this.brand;
}

public void setMaterial(String material) {
this.material = material;
}

public String getMaterial() {
return this.material;
}

public void setQuantity(int quantity) {
this.quantity = quantity;
}

public int getQuantity() {
return this.quantity;
}

public void setPrice(float price) {
this.price = price;
}

public float getPrice() {
return this.price;
}

public void setId(int id) {
this.id = id;
}

public int getId() {
return this.id;
}

}
Loading