Skip to content

Commit

Permalink
Merge pull request #26 from lucashoeft/tom/develop
Browse files Browse the repository at this point in the history
JavaDoc
  • Loading branch information
tzschmidt authored Jan 5, 2020
2 parents 3b5dcb7 + 5b465b1 commit 4be1f2e
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 73 deletions.
24 changes: 16 additions & 8 deletions src/com/lagerverwaltung/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
import java.util.logging.Logger;

/**
* The App Class contains the a runable main method and manages all actions before opening the main window and after
* The App Class contains the runnable main method and manages all actions before opening the main window and after
* closing
*
* @author ...
*/
public class App {

Expand All @@ -21,16 +24,19 @@ public class App {
private static Inventory inventory = new Inventory();

/**
* The configPath contains the location of the config file which contains the path for the .CSV database
* The configPath contains the location of the config file which contains the path for the .csv database
*/
private static String configPath = System.getProperty("user.dir") + "/Data/config.cfg";

private static final Logger logger = Logger.getLogger(App.class.getName());

/**
* Starts the software
* <p>
* 1. read Config
* 2. start GUI
* </p>
*
* @param args arguments which could be given over to this main method
*/
public static void main(String[] args) {
Expand All @@ -45,8 +51,8 @@ public static void main(String[] args) {
}

/**
* give .CSV database file over to inventory
* if config file does not exist create a new one
* Reads existing config file, if it doesn't exist, create one
*
* @param path path of the config file
*/
public static void readConfigFile(String path) {
Expand All @@ -71,11 +77,12 @@ public static void readConfigFile(String path) {
}
} catch (IOException e) {
logger.log(Level.WARNING,e.getMessage());
};
}
}

/**
* rewrites the config file to contain new_path as a new path
* Rewrites the config file to contain new_path as a new path
*
* @param config_path path of the config file
* @param new_path new path inside the config file
*/
Expand All @@ -97,9 +104,10 @@ public static void setConfigFile(String config_path, String new_path) {
}

/**
* deletes an empty config file at path
* Deletes an empty config file at path
*
* @param path path of config file
* @return return 1 if config file at path is empty
* @return return 1 if config file at path was deleted
*/
public static int clearConfigFile(String path){
File cfgFile = new File(path);
Expand Down
18 changes: 13 additions & 5 deletions src/com/lagerverwaltung/Category.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
public class Category {

/**
* name of the category
* Name of the category
*/
private String name;

/**
* count of items inside this category
* Count of items inside this category
*/
private Integer count;

Expand All @@ -27,6 +27,7 @@ public Category (String name){

/**
* Category Constructor
*
* @param name name of new category
* @param count amount of items inside this category
*/
Expand Down Expand Up @@ -64,22 +65,24 @@ public void setCount(int count) {
}

/**
* increase the amount of items inside category by one
* Increase the amount of items inside category by one
*/
public void increaseCount(){
this.count ++;
}

/**
* decrease the amount of items inside category by one
* Decrease the amount of items inside category by one
*/
public void decreaseCount(){
this.count --;
}

/**
* Checks if given object equals this Category
*
* @param o another object
* @return is the other object the same object as me?
* @return true if both objects are the same, else false
*/
public boolean equals(Object o){
if ((o == null) || (o.getClass() != this.getClass())){
Expand All @@ -90,6 +93,11 @@ public boolean equals(Object o){
}
}

/**
* Converts category into .csv compatible String
*
* @return .csv compatible String
*/
public String toStringCSV(){
return "-1," + name + ",-1,-1,-1,-1";
}
Expand Down
11 changes: 10 additions & 1 deletion src/com/lagerverwaltung/FileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
import java.util.logging.Level;
import java.util.logging.Logger;


/**
* The File Handler manages all actions concerning reading and writing the database
*
* @author ...
*/
public class FileHandler {

private static final Logger logger = Logger.getLogger(FileHandler.class.getName());

/**
* create Inventory object from a .CSV file at pathName
* Create Inventory object from a .CSV file at pathName
*
* @param pathName the path where the file is used from
* @return Inventory object
* @see Inventory
Expand Down Expand Up @@ -61,6 +65,10 @@ public Inventory readInventoryFromCSV(Path pathName) {

/**
* Takes an Inventory object and writes it to a .CSV file
* <p>
* creates backup, writes new file and then deletes backup
* </p>
*
* @param inventory inventory which is to be saved
*/
public void storeInventoryInCSV(Inventory inventory) {
Expand Down Expand Up @@ -119,6 +127,7 @@ private Boolean isCategory(String[] attributes) {

/**
* Creates a InventoryItem object from an Array that has been read from a .CSV file
*
* @param metadata String Array with all needed attributes of an InventoryItem object
* @return new InventoryItem containing metadata
*/
Expand Down
54 changes: 27 additions & 27 deletions src/com/lagerverwaltung/Inventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import java.util.logging.Logger;

/**
* during runtime an Inventory object contains all items of the database
*
* During runtime an Inventory object contains all items of the database
*
* @author ...
*/
public class Inventory {

Expand Down Expand Up @@ -43,6 +46,7 @@ public Inventory(){

/**
* Constructor for a new Inventory object
*
* @param path the path of the database .CSV file
*/
public Inventory(String path){
Expand All @@ -64,8 +68,9 @@ public String getPath() {
}

/**
* read file, parse file to object and save locally
* @param itemMap HashMap
* Sets itemMap and initializes storage and categories
*
* @param itemMap HashMap which contains all items
*/
public void setItemMap(HashMap<String, InventoryItem> itemMap) {
this.itemMap = itemMap;
Expand All @@ -74,8 +79,10 @@ public void setItemMap(HashMap<String, InventoryItem> itemMap) {
}

/**
* add a new item to itemMap.
* Add a new item to itemMap.
* <p>
* is successful when item doesn't exist yet and won't make shelf too heavy
*</p>
*
* @param item item to be added
* @return true if successful else return false
Expand Down Expand Up @@ -107,7 +114,7 @@ public boolean addNewItem(InventoryItem item) {
}

/**
* remove item from itemMap
* Remove item from itemMap
*
* @param name name of the item
* @return true if item removed else return false
Expand All @@ -134,6 +141,8 @@ public HashMap<String, InventoryItem> getItemMap() {
}

/**
* Returns specified item
*
* @param name name of an item
* @return item object with name
*/
Expand All @@ -143,15 +152,7 @@ public InventoryItem getItem(String name)
}

/**
* @param searchMask String which needs to be in all found items
* @return all items fitting the search mask
*/
public HashMap<String, InventoryItem> getItems(String searchMask) {
return itemMap;
}

/**
* increase the stock of an item
* Increase the stock of an item
*
* @param name name of the item
* @param count new stock = old stock + count
Expand All @@ -168,7 +169,7 @@ public boolean increaseStockBy(String name, int count){
}

/**
* decrease the stock of an item
* Decrease the stock of an item
*
* @param name name of the item
* @param count new stock= old stock - count
Expand All @@ -187,7 +188,8 @@ public boolean decreaseStockBy(String name, int count){
}

/**
* converting item list into csv-compatible string
* Converts item list into csv-compatible string
*
* @return csv-compatible string of the inventory
*/
public String toStringCSV() {
Expand Down Expand Up @@ -216,7 +218,7 @@ public void setShelfMap(HashMap<Integer, Shelf> shelfMap) {
}

/**
* add count new items to Storage if it doesn't make shelf too heavy
* Add count new items to Storage if it doesn't make shelf too heavy
*
* @param item item to be added
* @param count amount of items
Expand All @@ -226,11 +228,8 @@ public boolean addItemToStorage(InventoryItem item, int count){
// if shelf exists
if (shelfMap.containsKey(item.getShelf())){
// try to add Items
if (shelfMap.get(item.getShelf()).addToShelf(item, count)){
return true;
}
return shelfMap.get(item.getShelf()).addToShelf(item, count);
// change to heavy
return false;
}
else{
// create new shelf with items
Expand All @@ -244,7 +243,7 @@ public boolean addItemToStorage(InventoryItem item, int count){
}

/**
* remove count items from Storage
* Remove count items from Storage
*
* @param item item to be removed
* @param count amount of items to be removed
Expand All @@ -254,11 +253,8 @@ public boolean removeItemFromStorage(InventoryItem item, int count){
// if shelf exists
if (shelfMap.containsKey(item.getShelf())){
// try to remove items
if (shelfMap.get(item.getShelf()).removeFromShelf(item, count)){
return true;
}
return shelfMap.get(item.getShelf()).removeFromShelf(item, count);
// error in removal
return false;
}
else{
// shelf doesnt exists
Expand All @@ -274,6 +270,8 @@ public HashMap<String, Category> getCategoryMap(){
}

/**
* Add new category, if it doesn't exist already
*
* @param cat new categorie which is added to categoryMap
* @return true if successful, else return false
*/
Expand All @@ -290,6 +288,8 @@ public boolean addCategory(Category cat){
}

/**
* Remove category, if it exists
*
* @param cat category which is to be removed
* @return true if successful, else return false
*/
Expand All @@ -307,7 +307,7 @@ public boolean removeCategory(Category cat){
}

/**
* initialize storage with all valid shelves
* Initialize storage with all valid shelves
*/
private void initStorage(){
// get all used shelves
Expand Down
Loading

0 comments on commit 4be1f2e

Please sign in to comment.