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

Finished lab #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions .idea/Product-Inventory-Lab.iml

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

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.

38 changes: 38 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,42 @@
</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>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
81 changes: 81 additions & 0 deletions src/main/java/models/Coffee.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
115 changes: 115 additions & 0 deletions src/main/java/models/Console.java
Original file line number Diff line number Diff line change
@@ -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);
}

}
35 changes: 35 additions & 0 deletions src/main/java/models/Inventory.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
23 changes: 23 additions & 0 deletions src/main/java/models/MainApplication.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
4 changes: 4 additions & 0 deletions src/main/java/models/Mugs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package models;

public class Mugs {
}
Loading