diff --git a/out/production/SmartHusAS/itemhandler/ItemRegistryStorage.class b/out/production/SmartHusAS/itemhandler/ItemRegistryStorage.class index 0bd31d67eac67e4eb081a3e510ed78c9f4398a31..88e04843f404ab1ba2653cacc28c59f98a19c138 100644 Binary files a/out/production/SmartHusAS/itemhandler/ItemRegistryStorage.class and b/out/production/SmartHusAS/itemhandler/ItemRegistryStorage.class differ diff --git a/out/production/SmartHusAS/itemhandler/ItemTable.class b/out/production/SmartHusAS/itemhandler/ItemTable.class index 442db3f2213f5ccc4d9349b29243dec8b1ee370a..ff6ef31bcbb63fcfa13dcc3e35366c87080b93b6 100644 Binary files a/out/production/SmartHusAS/itemhandler/ItemTable.class and b/out/production/SmartHusAS/itemhandler/ItemTable.class differ diff --git a/out/production/SmartHusAS/itemhandler/SmartHouseApp.class b/out/production/SmartHusAS/itemhandler/SmartHouseApp.class index 5adcfdfe97bf434b34823bd5a45ed3a65a751949..3d3dab505e11e3db75bfc9fef790432b6edec8f9 100644 Binary files a/out/production/SmartHusAS/itemhandler/SmartHouseApp.class and b/out/production/SmartHusAS/itemhandler/SmartHouseApp.class differ diff --git a/out/production/SmartHusAS/itemhandler/UserInterface$1.class b/out/production/SmartHusAS/itemhandler/UserInterface$1.class index 716bb0c79d2084c42df0074b3457ec5b98f070e5..5d4d12e8901d62978358c5d6bf570b9553e22663 100644 Binary files a/out/production/SmartHusAS/itemhandler/UserInterface$1.class and b/out/production/SmartHusAS/itemhandler/UserInterface$1.class differ diff --git a/out/production/SmartHusAS/itemhandler/UserInterface.class b/out/production/SmartHusAS/itemhandler/UserInterface.class index 90f96c55a4a799e797d33ad924af154f579b0e5f..64758c5afad70e3865be0cc7147c9b99c9dd30b0 100644 Binary files a/out/production/SmartHusAS/itemhandler/UserInterface.class and b/out/production/SmartHusAS/itemhandler/UserInterface.class differ diff --git a/out/production/SmartHusAS/staticconstants/Category.class b/out/production/SmartHusAS/staticconstants/Category.class index f6becdfd5e4a003b3675c48c4e29584339d03d9d..80147563acc8c575213500194db125224e9d4123 100644 Binary files a/out/production/SmartHusAS/staticconstants/Category.class and b/out/production/SmartHusAS/staticconstants/Category.class differ diff --git a/out/production/SmartHusAS/utility/ItemSorter$1.class b/out/production/SmartHusAS/utility/ItemSorter$1.class index 012c41a64a41c528627e3ca0117654724a9da1f2..760b4ff8d196772780903a5434ac056773c70b30 100644 Binary files a/out/production/SmartHusAS/utility/ItemSorter$1.class and b/out/production/SmartHusAS/utility/ItemSorter$1.class differ diff --git a/out/production/SmartHusAS/utility/ItemSorter.class b/out/production/SmartHusAS/utility/ItemSorter.class index 101a3000a2e1e193bc1ee5e7b4f05f1d2cd3c3ca..581f7eecfb8657b187cc0b4050c0bccd87bb1f06 100644 Binary files a/out/production/SmartHusAS/utility/ItemSorter.class and b/out/production/SmartHusAS/utility/ItemSorter.class differ diff --git a/out/production/SmartHusAS/utility/Parameter.class b/out/production/SmartHusAS/utility/Parameter.class index 3e0c98440a4b46c51d0282fe391576eb7215c0af..b4ae8b1ca155152821ad3039dc9d00a035bc3c06 100644 Binary files a/out/production/SmartHusAS/utility/Parameter.class and b/out/production/SmartHusAS/utility/Parameter.class differ diff --git a/resources/ItemRegistryStorage.txt b/resources/ItemRegistryStorage.txt index 3699c43faafccc96a01418d31f842f26cee01bec..ae5c38da558917beb646a613bab0ca3725f48edc 100644 Binary files a/resources/ItemRegistryStorage.txt and b/resources/ItemRegistryStorage.txt differ diff --git a/src/itemhandler/Item.java b/src/itemhandler/Item.java index bd4423df791801ecbce21a4c6851171950c7a4f9..67329e966c4245f0663c260be9cb99ca1a373d48 100644 --- a/src/itemhandler/Item.java +++ b/src/itemhandler/Item.java @@ -64,8 +64,8 @@ public class Item implements Serializable } /** - * gets and returns item information mapped as a linked hashmap maintain order used in java - * table frame in ItemTable. + * gets and returns item information mapped as a linked hashmap maintain order in the order + * String, int, double used in JTable frame in ItemTable. * * @return itemHashMap item details mapped as a type HashMap, * key is parameter name while value is parameter value diff --git a/src/itemhandler/ItemRegistryStorage.java b/src/itemhandler/ItemRegistryStorage.java index 15f775f965339d2ed97eb9558c182e975ef79ffc..0e1dc539a5fe8651275ae1babd088beb1cf05e3d 100644 --- a/src/itemhandler/ItemRegistryStorage.java +++ b/src/itemhandler/ItemRegistryStorage.java @@ -23,9 +23,9 @@ public class ItemRegistryStorage */ public void saveFile(Map<String, Item> itemMap) throws IOException { - try (ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(PATH))) + try (ObjectOutputStream objectOutput = new ObjectOutputStream(new FileOutputStream(PATH))) { - os.writeObject(itemMap); + objectOutput.writeObject(itemMap); } } @@ -37,10 +37,10 @@ public class ItemRegistryStorage */ public Map<String, Item> readFile() throws ClassNotFoundException, IOException { - try (ObjectInputStream is = new ObjectInputStream(new FileInputStream(PATH))) + try (ObjectInputStream objectInput = new ObjectInputStream(new FileInputStream(PATH))) { - // Unable to resolve warning even with an instanceof if statement. - return ((HashMap<String, Item>) is.readObject()); + // Unable to resolve warning even with the use of an instanceof if statement. + return ((HashMap<String, Item>) objectInput.readObject()); } } } diff --git a/src/itemhandler/ItemTable.java b/src/itemhandler/ItemTable.java index b7cbc4315cde66d910df6491d3f5dad51684f288..85103b2acd25b298a5507c85d0be0ddff2387f7c 100644 --- a/src/itemhandler/ItemTable.java +++ b/src/itemhandler/ItemTable.java @@ -22,6 +22,20 @@ public class ItemTable */ public void displayItemTable(Map<String, Item> itemMap) + { + JFrame javaFrame = new JFrame(); + javaFrame.pack(); + JTable javaTable = new JTable(itemMapToMultiStringArray(itemMap), new Item() + .getItemInformationMapped().keySet().toArray(String[]::new)); + javaTable.setAutoCreateRowSorter(true); + javaTable.setBounds(50, 40, 400, 280); + JScrollPane javaScroll = new JScrollPane(javaTable); + javaFrame.add(javaScroll); + javaFrame.setSize(1500, 500); + javaFrame.setVisible(true); + } + + private String[][] itemMapToMultiStringArray(Map<String, Item> itemMap) { Collection<String> returnString; @@ -37,17 +51,6 @@ public class ItemTable { listOfStringLists2[index] = listOfListsOfItemParameters.get(index); } - - JTable javaTable; - JFrame javaFrame = new JFrame(); - javaFrame.pack(); - javaTable = new JTable(listOfStringLists2, new Item().getItemInformationMapped().keySet() - .toArray(String[]::new)); - javaTable.setAutoCreateRowSorter(true); - javaTable.setBounds(50, 40, 400, 280); - JScrollPane javaScroll = new JScrollPane(javaTable); - javaFrame.add(javaScroll); - javaFrame.setSize(1500, 500); - javaFrame.setVisible(true); + return listOfStringLists2; } } diff --git a/src/itemhandler/SmartHouseApp.java b/src/itemhandler/SmartHouseApp.java index d46cc4a006a45ab365338ccc8bcd7975bc7d0c2c..dd2a23901bb19c3710ce92ab364709e404897df4 100644 --- a/src/itemhandler/SmartHouseApp.java +++ b/src/itemhandler/SmartHouseApp.java @@ -12,10 +12,7 @@ public class SmartHouseApp /** - * Main function, constructs object using itemPackage.UserInterface class methods and - * itemPackage.Item class - * enables use to input parameters to construct item, then change and see item values - * through setters and getters through itemPackage.UserInterface methods, Scanner and HashMap. + * Main function, creates new UserInterface object then exits JVM. * @param args main function signature. */ diff --git a/src/itemhandler/UserInterface.java b/src/itemhandler/UserInterface.java index 67331a8b038f3852deb9b5775e3a96f6c88f2f31..debd1dea62586ebf993361bcc12a313b546851aa 100644 --- a/src/itemhandler/UserInterface.java +++ b/src/itemhandler/UserInterface.java @@ -23,7 +23,8 @@ import utility.Parameter; /** * User interface class handles the usage of all other classes except SmartHouseApp and allows - * user to change and see item registry based on user input from terminal. + * user to change and see item registry filtered, sorted or plain based on user input from terminal + * through Scanner. */ public class UserInterface { diff --git a/src/staticconstants/Category.java b/src/staticconstants/Category.java index 1dcd4091471f1d72a72ce1846bc04d1738afb0c7..ad4cf45d6c8bec7bd2e21788389d42e09c5fb545 100644 --- a/src/staticconstants/Category.java +++ b/src/staticconstants/Category.java @@ -32,7 +32,7 @@ public enum Category * @return categoryNumber */ - public int getCategoryNumber() + private int getCategoryNumber() { return categoryNumber; } diff --git a/src/staticconstants/InvalidReturn.java b/src/staticconstants/InvalidReturn.java index 8f8c1610a9dfdf441315b3ea0ee57ecf66738853..9e842bec6a43f692edacc76a6ebc074ebb29f67e 100644 --- a/src/staticconstants/InvalidReturn.java +++ b/src/staticconstants/InvalidReturn.java @@ -2,8 +2,8 @@ package staticconstants; import java.util.Arrays; -/**The static error return messages to be printed from itemHandler. - * +/** + * The static error return messages to be printed from itemHandler. */ public class InvalidReturn { diff --git a/src/staticconstants/ValidColors.java b/src/staticconstants/ValidColors.java index da2aaedad761ef413c795ad2bb4eb7b786673b13..89325d8e83c32f1aa21746349df81be5552907f7 100644 --- a/src/staticconstants/ValidColors.java +++ b/src/staticconstants/ValidColors.java @@ -1,7 +1,7 @@ package staticconstants; -/** All valid colors for the itemColor parameter. - * +/** + * All valid colors for the itemColor parameter. */ public enum ValidColors { diff --git a/src/utility/ItemSorter.java b/src/utility/ItemSorter.java index 41c4161710a7a05902fe64776c559f6e4834de27..5701f37f64de6b5ccd54ce0c6af6df16f29330a5 100644 --- a/src/utility/ItemSorter.java +++ b/src/utility/ItemSorter.java @@ -17,6 +17,9 @@ import staticconstants.ItemFieldEnum; public class ItemSorter { + /** + * private constructor to hide implicit public one. + */ private ItemSorter() { diff --git a/src/utility/Parameter.java b/src/utility/Parameter.java index b9fafdfe4d97f9ba7cd9204404a1482741094352..a53a2b1af1594f37197b7c95b3938ebf5d8d113b 100644 --- a/src/utility/Parameter.java +++ b/src/utility/Parameter.java @@ -37,7 +37,7 @@ public class Parameter return intToCheckNegative > 0; } /** Checks if double is negative, returns false when negative and - * true when positive or zero. + * true when positive. * * @param doubleToCheckNegative int to be checked * @return validString @@ -45,8 +45,7 @@ public class Parameter public static boolean checkValid(double doubleToCheckNegative) { - isValid = doubleToCheckNegative > 0; - return isValid; + return doubleToCheckNegative > 0; } /** Checks if color typed is among the valid colors.