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
3 changes: 2 additions & 1 deletion .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.

15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,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>
55 changes: 55 additions & 0 deletions src/main/java/models/DVDs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package models;

public class DVDs {
private int id;
private String name;
private int qty;
private float price;

public DVDs(Integer id, String name, Integer qty, Float price) {
this.id = id;
this.name = name;
this.qty = qty;
this.price = price;
}

public DVDs() {

}

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


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


public String getName() {
return this.name;
}



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

public Integer getQty(){
return this.qty;
}


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

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



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

public class RunningShoes {
private int id;
private String name;
private String brand;
private double size;
private int qty;
private float price;




public RunningShoes(Integer id, String name, String brand, Double size, Integer qty, Float price) {
this.id = id;
this.name = name;
this.brand = brand;
this.size = size;
this.qty = qty;
this.price = price;
}

public RunningShoes() {

}

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


public String getName() {
return this.name;
}

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

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

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

public Double getSize() {
return this.size;
}

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

public Integer getQty(){
return this.qty;
}


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

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

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




}


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

public class DVDs {
}
35 changes: 35 additions & 0 deletions src/main/java/services/RunningShoes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package services;

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

public class RunningShoes {
private static int nextId = 1; // (1)

private List<models.RunningShoes> inventory = new ArrayList<>();

public models.RunningShoes create(Integer id, String name, String brand, double size, Integer quantity, float price) {

models.RunningShoes createdShoes = new models.RunningShoes(nextId++, name, brand, size, quantity, price);

inventory.add(createdShoes);


return createdShoes;
}

// read
public RunningShoes findRunningShoes(int id) {
for(int i = 0; i<inventory.size(); i++){
if(inventory.get(i).equals(id)){
return inventory.get(i).getId();
}
}

return null;
}




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

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class DVDsTest {
@Test
public void setNameTest() {
// Given
String expected = "OZWEEGO";

// When
DVDs nameTest = new DVDs();
nameTest.setName(expected);

// Then
Assertions.assertEquals(expected, nameTest.getName());
}


@Test
public void setQtyTest() {
// Given
Integer qtyExpected = 50;
DVDs dvDs = new DVDs();
dvDs.setQty(qtyExpected);


// When
Integer qtyActual = dvDs.getQty();

// Then
Assertions.assertEquals(qtyExpected, qtyActual);
}


@Test
public void setPriceTest() {
// Given
Float priceExpected = 30F;
DVDs dvDs = new DVDs();
dvDs.setPrice(priceExpected);

// When
Float priceActual = dvDs.getPrice();


// Then
Assertions.assertEquals(priceExpected, priceActual, 0.01);




}

@Test
public void constructorTest() {
// Given

int expectedId = 6;
String expectedName = "Stan Smith";
Integer expectedQty = 10;
Float expectedPrice = 80.00f;

// When
DVDs testDVD = new DVDs(expectedId,expectedName, expectedQty, expectedPrice);


// Then
Assertions.assertEquals(expectedId, testDVD.getId());
Assertions.assertEquals(expectedName, testDVD.getName());
Assertions.assertEquals(expectedQty, testDVD.getQty());
Assertions.assertEquals(expectedPrice, testDVD.getPrice());
}
}
Loading