Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonxubw committed Mar 6, 2017
0 parents commit 86d797e
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .idea/compiler.xml

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

3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

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

19 changes: 19 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

11 changes: 11 additions & 0 deletions SE Project.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
55 changes: 55 additions & 0 deletions src/Item.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

public class Item
{
String item_description; // Stores the name for the item description
int quantity; // Stores the quantity of the item
double price; // Stores the price of the item
String date_purchased; // Stores the date purchased for the item
String time_stamp; //Stores the time stamp for the item


// Constructor method
public Item(String item_description, int quantity, double price, String date_purchased, String time_stamp){
super();
this.item_description = item_description;
this.quantity = quantity;
this.price = price;
this.date_purchased = date_purchased;
this.time_stamp = time_stamp;
}

//get and set methods to access and modify the variables
public String getItem_Description(){
return item_description;
}
public int getQuantity(){
return quantity;
}
public double getPrice(){
return price;
}
public String getDate_purchased(){
return date_purchased;
}
public String getTime_stamp(){
return time_stamp;
}

public void setItem_description(String item_description){
this.item_description = item_description;
}
public void setQuantity(int quantity){
this.quantity = quantity;
}
public void setPrice(double price){
this.price = price;
}
public void setDate_purchased(String date_purchased){
this.date_purchased = date_purchased;
}
public void setTime_stamp(String time_stamp){
this.time_stamp = time_stamp;
}


}
22 changes: 22 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.Hashtable;
import java.util.Set;

public class Main {
public static void main (String args[]) throws Exception{
Hashtable<Integer, Item> hash = new Hashtable<Integer, Item> (); //Creates a hash table called "hash" that stores an integer as key and "Item" object as value

hash.put(1, new Item("Orange", 5, 1.25, "01-24-17", "02-31-18")); //Add new items to our hashtable
hash.put(2, new Item("Apple", 10, 2.25, "05-21-17", "05-12-18"));
hash.put(3, new Item("Banana", 23, 0.99, "02-01-17", "02-01-18"));

Set<Integer> keys = hash.keySet(); //Get a set view of the keys contained in the table

System.out.println("Inventory ID | Item Description | Quantity | Price | Date Purchased | Time Stamp"); //Prints out the headers of each field

// Iterate through the items in the hashtable and retrieve the variables in the object Item, and print them out corresponding to its headers
for (Integer key : keys){
Item item = hash.get(key);
System.out.println(key + " | " + item.getItem_Description() + " | " + item.getQuantity() + " | " + item.getPrice() + " | " + item.getDate_purchased() + " | " + item.getTime_stamp());
}
}
}

0 comments on commit 86d797e

Please # to comment.