Skip to content

Inventory #7

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

Open
wants to merge 4 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
1 change: 1 addition & 0 deletions Humans and Superhumans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36" version="6.0.2.8" editor="www.draw.io" type="device"><diagram name="Page-1">7VlNj9s2EP01BtpDAlGynd2j7d1kD9t0URdoeqQlWiJCiQZFf+XXdygOJVmSu0y8bnrwwliITzPkkO9xNJRG0SI/fFJ0k/0mEyZGYZAcRtHDKAw/kAD+G+BogWg6tUCqeGIh0gBL/o0hiH7pliesPDHUUgrNN6dgLIuCxfoEo0rJ/anZWorTUTc0ZT1gGVPRR//iic4sejcJGvyJ8TRzI5MA76xo/DVVclvgeKMwWld/9nZOXV9oX2Y0kfsWFD2OooWSUtur/LBgwiytWzbr9/HM3TpuxQrt4xBahx0VW5z60zanRYnR6aNbkXLPc0ELaM0znQsACVyuZaGXaGTaVPC0gOsYhmcKgB1TmsO6zvCGlhtA44yL5Jke5dYEWWpYNNeaZ1Lxb9AtdWPAbaVRIuH0xGJpPAEOAFWsBJsXN3NSQ8+01GgTSyHopuSrOuCcqpQXc6m1zNHIzfQjF2IhhVTVAjgaozmuGEyMHc6uOqm5hC3CZM60OoIJOtwj+7g7xtjcN1Ijd4hlLZlFEYIU5Z3WPTcUwwWyPMx41GMcJlfQHBozwJda8SIdhVNhyEj4Di5TXU07qjaNMeIwTbSA4U6MhvxSViRGDf3+fbxlHG83VHNZ/GgPNElACqWPe0f1QLE+VXyplfzKnC4KWe2IdUsqCLmdINhan90H5YbGEMxzZfMwbpA/kHQD7TOu2RJwE9Me0i1gEvpbiypxZDxJWGHULjXV1Erb6HgjgaZKKJM5/EA6i+D9ZDSBeS2gTZo2/Iy50gtZwPwor1TMYN/sWal9JR8OSx41Hk79NE6C8eUaHw9ovMOs4N1cZpl16Z78EK05kGFGcDz+aWh+eEd6XEd9rqMBDgVdMfEiS27l/6CsbYfb/4A+EnnmqLvL2ZsMZaiU6c+QpH759fU0VaKptUGHnYTuvytn6VlaD9dKeL2xjBnc9x7Hc/RPVdL0nC8af+eMPSP5vU7AntG0HK4T0cwmdM9wnPWFsdweDVfLLXeez4b78PLs4o4YrfSy3G6YutW91697o+lPLHwJGXquVMzlVfyvpZKMKfn5TKHsk7hKI7PZiguuj7da9KoJhwTDOvwZxSjpn7Fv1eiFBHqXo+QtEsfgkdmUIS53+BYitf2lpekTpiLPgWvz65Rjy1Zi84zoxOVWmP1P8yTxfUCT6Vvss/6xvXov1SUYzjoz844XWishTSE0B8iULch3i3qWpMwVarBYmUxlQcVjg/qRzg5cfzEcvQ+CKbb/rtqT+zG2X5jiMGdT/lVcwiKr4xcXh2mgR02OCe7fKymYt9yq2FlhIoLCEHZd67B8tuB6h70oJuA8tjsdbYgr7OlFVide1w3pvLAMP3TotlGiV/t1c6ej2rF+EHc6slPrdQR802PLDPfJ2YAj0g140lGi7bHRZb12flLtv6NwfDU6rcrw1uZuyfIV0a2wLrdP3Hn9TWGoLK+OIvaUQIJaWvhhBEcf1d8bXssH47eV05mtD83mE4dd/uYzUvT4Dw==</diagram></mxfile>
1 change: 1 addition & 0 deletions Product Inventory Control.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36" version="6.0.2.8" editor="www.draw.io" type="device"><diagram name="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T/WFLCl3ZkjaIi3ju0ZP1zS/bO9JHgxKLwDi3Zt3pJoHF8D9WnQtvm/dOtVKdYZD9nx5zO/5V9fg0gQb2taC4C3Ze3FTjdfpNUru18Wxdc/QM=</diagram></mxfile>
33 changes: 33 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>crame.randall</groupId>
<artifactId>ReusingClassesLabs</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
52 changes: 52 additions & 0 deletions src/main/java/ReusingClassesLabs/Human.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package ReusingClassesLabs;

/**
* Created by randallcrame on 1/18/17.
*/
public class Human {
protected String name;
protected int age;
protected String gender;
protected String occupation;
protected String address;


public String getName(){
return name;
}

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

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public String getGender(){
return gender;
}

public void setGender(String gender){
this.gender = gender;
}

public String getOccupation(){
return occupation;
}
public void setOccupation(String occupation){
this.occupation = occupation;
}

public String getAddress(){
return address;
}

public void setAddress(String address){
this.address = address;
}
}
21 changes: 21 additions & 0 deletions src/main/java/ReusingClassesLabs/InventoryManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ReusingClassesLabs;

import java.util.ArrayList;

/**
* Created by randallcrame on 1/18/17.
*/
public class InventoryManager {
private ArrayList<Product> inventoryList = new ArrayList<>();


public void addToInventory(Product product){
inventoryList.add(product);
}
public double sumOfInventory(){
double sum = 0;
for (Product item : inventoryList)
sum += item.getPrice() * item.getQuantity();
return sum;
}
}
48 changes: 48 additions & 0 deletions src/main/java/ReusingClassesLabs/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ReusingClassesLabs;


/**
* Created by randallcrame on 1/18/17.
*/
public class Main {
public static void main (String[] args){
RotateArray object = new RotateArray();

int array[] = {1,2,3,4,5};

System.out.println("Original: ");
for(int i = 0; i < array.length; i++) {
System.out.print(array[i]);
}
System.out.println();

object.rotateArray(array, 2);
System.out.println("Rotated: ");
for(int j = 0; j < array.length; j++) {
System.out.print(array[j]);
}

Human bob = new Human();
SuperHuman steve = new SuperHuman();
Human stacy = new SuperHuman();

bob.setName("jim");
System.out.println(bob.getName());
steve.setAlignment("Good");
System.out.println(steve.getAlignment());
stacy.setGender("N/A"); //unable to set SuperHuman fields.
System.out.println(stacy.getGender());

Product pepsi = new Product("pepsi",3.99, 500);
Product popcorn = new Product("popcorn", 2.50, 3000);
Product skittles = new Product("skittles", 4.95, 1000);
InventoryManager theaterInventoryList = new InventoryManager();
theaterInventoryList.addToInventory(pepsi);
theaterInventoryList.addToInventory(popcorn);
theaterInventoryList.addToInventory(skittles);
System.out.print( "Total: " + theaterInventoryList.sumOfInventory());

}

}

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

/**
* Created by randallcrame on 1/18/17.
*/
public class Product {
private double price;
private final String id;
private int quantity;

public Product(String id, double price, int quantity) {
this.price = price;
this.id = id;
this.quantity = quantity;
}

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

public double getPrice(){
return price;
}

public String getId(){
return id;
}

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

public int getQuantity(){
return quantity;
}
}
24 changes: 24 additions & 0 deletions src/main/java/ReusingClassesLabs/RotateArray.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ReusingClassesLabs;

import java.util.ArrayList;

/**
* Created by randallcrame on 1/18/17.
*/
public class RotateArray extends ArrayList {
//private int currentArrayHolder, temporaryValue;

public void rotateArray(int array[], int rotate) {
int currentArrayHolder, temporaryValue;

for (int i = 0; i < rotate; i++) {
temporaryValue = array[0];
for (currentArrayHolder = 0; currentArrayHolder < array.length-1; currentArrayHolder++) {
array[currentArrayHolder] = array[currentArrayHolder+1];
}
array[array.length-1] = temporaryValue;


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

/**
* Created by randallcrame on 1/18/17.
*/
public class SuperHuman extends Human {
protected String alignment;
protected String heroName;
protected String superAbility;

public String getAlignment(){
return alignment;
}

public void setAlignment(String alignment){
this.alignment = alignment;
}

public String getHeroName(){
return heroName;
}

public void setHeroName(String heroName){
this.heroName = heroName;
}

public String getSuperAbility(){
return superAbility;
}

public void setSuperAbility(String superAbility){
this.superAbility = superAbility;
}
}
22 changes: 22 additions & 0 deletions src/test/java/ReusingClassesLabsTest/InventoryManagerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package ReusingClassesLabsTest;

import ReusingClassesLabs.InventoryManager;
import ReusingClassesLabs.Product;
import org.junit.Assert;
import org.junit.Test;

/**
* Created by randallcrame on 1/18/17.
*/
public class InventoryManagerTest {

Product pepsi = new Product("pepsi",3.92, 2000);
InventoryManager inventoryListHouston = new InventoryManager();
@Test
public void sumOfInventoryTest(){
inventoryListHouston.addToInventory(pepsi);
double expected = 7840;
double actual = inventoryListHouston.sumOfInventory();
Assert.assertEquals(expected,actual, 0.0);
}
}