Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #19

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Dev #19

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.

18 changes: 17 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,20 @@
</plugins>
</build>

</project>
<dependencies>
<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>

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

import services.SneakerService;

public class App {
private SneakerService sneakerService = new SneakerService();

public static void main(String... args){
App application = new App();
application.init();
}

private void init() {
// application logic here
// call methods to take user input and interface with services


Console.printWelcome();
Console.mainMenu();
}



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

import models.Hat;
import models.Sneaker;
import services.HatService;
import services.SneakerService;

import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Console {

public static class Inventory {
private SneakerService sneakerService = new SneakerService();
private HatService hatService = new HatService();

public SneakerService getSneakerService() {
return this.sneakerService;
}
public HatService getHatService() {
return this.hatService;
}

}
private static Inventory inventory = new Inventory();

public static void sampleInventory() {
SneakerService sneakerService = inventory.getSneakerService();
HatService hatService = inventory.getHatService();

sneakerService.create("Air Jordan 1", "Nike", "Basketball", 10.5, 200, 170.00F);
sneakerService.create("Nite Joggers", "Adidas", "Running", 10.5, 50, 120.00F);
sneakerService.create("Air Force 1", "Nike", "Casual", 10.5, 100, 90.00F);

hatService.create("Fitted", "Baseball", "New York Yankees", "Medium", 20, 39.99F);
hatService.create("Snap-back", "Basketball", "Los Angeles Lakers", "Large", 20, 44.99F);
hatService.create("Strap-back", "Football", "Philadelphia Eagles", "Medium", 20, 34.99F);
}

public static void print(String input) {
System.out.println(input);
}
public static void printWelcome() {
System.out.println("" +
"**************************************************\n" +
"*** Welcome and Bienvenue ***\n" +
"*** to ***\n" +
"*** ZipCo Inventory Manager ***\n" +
"**************************************************");
}

//==============================================================================================//
// =================================== ~*~ MAIN MENU ~*~ ====================================== //
// =============================================================================================//
public static void mainMenu() {
Scanner scanner = new Scanner(System.in);
Integer input;
print(" ~*~ MAIN MENU ~*~ \n" +
"Please enter a number from the menu options");
print("1 - Show existing products");
print("2 - Update products");
print("3 - Delete products");
print("Press any other numbers to Quit \n > ");
input = scanner.nextInt();

switch(input) {
case 1:
// Show Existing products options
productSelector();
break;

case 2:
// Show Update products options
updateSelector();
break;

case 3:
// Show Delete products options
deleteSelector();
break;

default:
print("Quiting Product Inventory Application ... Goodbye");
}
}



//=============================================================================================//
// ================================ SHOW EXISTING PRODUCTS OPTIONS =========================== //
//=============================================================================================//
private static void productSelector() {
Scanner scanner = new Scanner(System.in);
Integer input;
print("Enter the number corresponding to the product");
print("1 - Sneakers");
print("2 - Hats");
print("~*~ OR ~*~");
print("3 - Main Menu");

input = scanner.nextInt();

switch(input) {
case 1:
// Show sneakers inventory information
printSneakersList(inventory.getSneakerService().findAll());
productSelector();
break;
case 2:
// Show hats inventory information
printHatsList(inventory.getHatService().findAll());
productSelector();
break;
case 3:
// Go back to main menu
mainMenu();
break;
default:
print("Please enter a valid number ... Try again!");
productSelector();
}

}

//=================================================================================================//
// ================================ INFO GOES INTO PRODUCT SELECTOR ============================ //
//=================================================================================================//
public static void printSneakersList (Sneaker[] list) {
ArrayList<Sneaker> sneakerList = new ArrayList<>(Arrays.asList(list));

for (Sneaker element : sneakerList) {
print(element.getName() + element.getBrand() + element.getSport() + element.getSize() + element.getQuantity() + element.getPrice());
}
}
public static void printHatsList (Hat[] list) {
ArrayList<Hat> hatList = new ArrayList<>(Arrays.asList(list));

for (Hat element : hatList) {
print(element.getType() + element.getSport() + element.getTeam() + element.getSize() + element.getQuantity() + element.getPrice());
}
}

//=================================================================================================//
// ================================ SHOW UPDATE PRODUCTS OPTIONS ================================= //
//=================================================================================================//
private static void updateSelector() {
Scanner scanner = new Scanner(System.in);
Integer input;
print("Enter the number corresponding to the product");
print("1 - Sneakers");
print("2 - Hats");
print("~*~ OR ~*~");
print("3 - Main Menu");

input = scanner.nextInt();

switch (input) {
case 1:
// Allow user to update sneakers

updateSelector();
break;
case 2:
// Allow user to update hats

updateSelector();
break;
case 3:
// Go back to main menu
mainMenu();
break;
default:
print("Please enter a valid number ... Try again!");
updateSelector();
}
}




//=================================================================================================//
// ================================ SHOW DELETE PRODUCTS OPTIONS ================================= //
//=================================================================================================//

private static void deleteSelector() {
Scanner scanner = new Scanner(System.in);
Integer input;
print("Enter the number corresponding to the product");
print("1 - Sneakers");
print("2 - Hats");
print("~*~ OR ~*~");
print("3 - Main Menu");

input = scanner.nextInt();

switch (input) {
case 1:
// Allow user to delete sneaker

deleteSelector();
break;
case 2:
// Allow user to delete hat

deleteSelector();
break;
case 3:
// Go back to main menu
mainMenu();
break;
default:
print("Please enter a valid number ... Try again!");
deleteSelector();
}
}


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

public class Hat {
private int hatId;
private String type; //fitted, snapback or strapback
private String sport; //baseball, basketball, NFL
private String team;
private String size; //small/ medium, large
private int quantity;
private float price;

public Hat(){
this.hatId = Integer.MAX_VALUE;
this.type = "";
this.sport = "";
this.team = "";
this.size = "";
this.quantity = Integer.MAX_VALUE;
this.price = Float.MAX_VALUE;
}

public Hat (int hatId, String type, String sport, String team, String size, int quantity, float price) {
this.hatId = hatId;
this.type = type;
this.sport = sport;
this.team = team;
this.size = size;
this.quantity = quantity;
this.price = price;
}

//================ SETTERS ================//
public void setHatId(int hatId) {
this.hatId = hatId;
}

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

public void setSport(String sport) {
this.sport = sport;
}

public void setTeam(String team) {
this.team = team;
}

public void setSize(String size) {
this.size = size;
}

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

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

//================ GETTERS ================//
public int getHatId() {
return hatId;
}

public String getType() {
return type;
}

public String getSport() {
return sport;
}

public String getTeam() {
return team;
}

public String getSize() {
return size;
}

public int getQuantity() {
return quantity;
}

public float getPrice() {
return price;
}


}
Loading