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
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.

2 changes: 1 addition & 1 deletion .idea/misc.xml

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

16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<artifactId>ProductInventoryLab</artifactId>
<version>1.0-SNAPSHOT</version>


<build>
<plugins>
<plugin>
Expand All @@ -22,4 +23,19 @@
</plugins>
</build>

<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>
82 changes: 82 additions & 0 deletions src/main/java/models/Sneaker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package models;

public class Sneaker {
private Integer id;
private String name;
private String brand;
private String sport;
private int size;
private int qty;
private float price;

public Sneaker(){
this(0, null, null, null, 0, 0, 0);
}

public Sneaker(Integer id, String name, String brand, String sport, int size, int qty, float price) {
this.id = id;
this.name = name;
this.brand = brand;
this.sport = sport;
this.size = size;
this.qty = qty;
this.price = price;
}


public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Integer getId() {
return id;
}

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

public String getBrand() {
return brand;
}

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

public String getSport() {
return sport;
}

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

public int getSize() {
return size;
}

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

public int getQty() {
return qty;
}

public void setQty(int qty) {
this.qty = qty;
}

public float getPrice() {
return price;
}

public void setPrice(float price) {
this.price = price;
}
}
82 changes: 82 additions & 0 deletions src/main/java/models/Whiskey.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package models;

public class Whiskey {
private Integer id;
private String name;
private String brand;
private String location;
private int size;
private int qty;
private float price;

public Whiskey(){
this(0, null, null, null, 0, 0, 0);
}

public Whiskey(Integer id, String name, String brand, String location, int size, int qty, float price) {
this.id = id;
this.name = name;
this.brand = brand;
this.location = location;
this.size = size;
this.qty = qty;
this.price = price;
}


public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Integer getId() {
return id;
}

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

public String getBrand() {
return brand;
}

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

public String getLocation() {
return location;
}

public void setLocation(String location) {
this.location = location;
}

public int getSize() {
return size;
}

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

public int getQty() {
return qty;
}

public void setQty(int qty) {
this.qty = qty;
}

public float getPrice() {
return price;
}

public void setPrice(float price) {
this.price = price;
}
}
58 changes: 58 additions & 0 deletions src/main/java/services/SneakerService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package services;

import models.Sneaker;

import java.util.ArrayList;
import java.util.List;

public class SneakerService {
private static Integer nextId = 1;

public List<Sneaker> getInventory() {
return inventory;
}

private List<Sneaker> inventory = new ArrayList<>();

public Sneaker create(String name, String brand, String sport, int size, int quantity, float price) {

Sneaker createdSneaker = new Sneaker(nextId++, name, brand, sport, size, quantity, price);

inventory.add(createdSneaker);

return createdSneaker;
}



//read
public Sneaker findSneaker(Integer id) {
for (Sneaker s : inventory){
if (id.equals(s.getId())){
return s;
}
}
return null;
}

//read all
public Sneaker[] findAll() {
Sneaker[] array = new Sneaker[inventory.size()];
array = inventory.toArray(array);
return array;
}

//delete
public boolean delete(Integer id) {
// should remove the object with this id from the ArrayList if exits and return true.
// Otherwise return false

for (Sneaker s : inventory){
if (id.equals(s.getId())){
inventory.remove(s);
return true;
}
}
return false;
}
}
60 changes: 60 additions & 0 deletions src/main/java/services/WhiskeyService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package services;

import models.Sneaker;
import models.Whiskey;

import java.util.ArrayList;
import java.util.List;

public class WhiskeyService {

private static Integer nextId = 1;

public List<Whiskey> getInventory() {
return inventory;
}

private List<Whiskey> inventory = new ArrayList<>();

public Whiskey create(String name, String brand, String location, int size, int quantity, float price) {

Whiskey createdWhiskey = new Whiskey(nextId++, name, brand, location, size, quantity, price);

inventory.add(createdWhiskey);

return createdWhiskey;
}



//read
public Whiskey findWhiskey(Integer id) {
for (Whiskey w : inventory){
if (id.equals(w.getId())){
return w;
}
}
return null;
}

//read all
public Whiskey[] findAll() {
Whiskey[] array = new Whiskey[inventory.size()];
array = inventory.toArray(array);
return array;
}

//delete
public boolean delete(Integer id) {
// should remove the object with this id from the ArrayList if exits and return true.
// Otherwise return false

for (Whiskey w : inventory){
if (id.equals(w.getId())){
inventory.remove(w);
return true;
}
}
return false;
}
}
Loading