Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • Lucas/smart-hus-as
1 result
Select Git revision
  • main
1 result
Show changes
Commits on Source (2)
Showing
with 35 additions and 32 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -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
......
......@@ -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());
}
}
}
......@@ -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;
}
}
......@@ -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.
*/
......
......@@ -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
{
......
......@@ -32,7 +32,7 @@ public enum Category
* @return categoryNumber
*/
public int getCategoryNumber()
private int getCategoryNumber()
{
return categoryNumber;
}
......
......@@ -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
{
......
package staticconstants;
/** All valid colors for the itemColor parameter.
*
/**
* All valid colors for the itemColor parameter.
*/
public enum ValidColors
{
......
......@@ -17,6 +17,9 @@ import staticconstants.ItemFieldEnum;
public class ItemSorter
{
/**
* private constructor to hide implicit public one.
*/
private ItemSorter()
{
......
......@@ -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.
......