-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 86d797e
Showing
7 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
} |