Keep an Eye on It: Salary Checker is a Java project developed to better manage your monthly expenses through the years.
- Class
- Config
- Exception
- Output
- Main
- Each expense has an amount, a category, an id and a description.
- Each Salary has a single income, and several outcomes.
All the outcomes are stored in an HashMap with key: Integer (auto incrementing id) and a value (outcome).
It has these methods worth mentioning:- Prints the outcomes stored in the Salary Hashmap.
- Several methods to edit a single expense description, outcome or category
- Used to better display the Salary data.
- Displays all the infos related to a Salary, such as income, gain and expenses value, description, n_ID, category
- Displays all the infos related to a Salary, such as expenses value, description, category
- Displays all the infos related to the outcome
- Displays expenses grouped by category and ordered by amount.
- It has a String year and an HashMap for the year months.
- Returns the HashMap which represents the year months.
- Year implements Comparable, compareTo is used to set the year String as parameter to order the ArrayList in the main.
-
It gives persistence to the program by loading all the already saved values and by storing the new ones into files that can be used as the project storage system.
It has 2 methods:-
Given a YEARS ArrayList, the method iterates through it and saves all its data in a txt file, created in order to save the data and making therefore possible for the readingFile method to load the already existing data.
Everytime it's called, it overwrites the txt file deleting the old content. -
Given a YEARS ArrayList, the method iterates through it and saves all its data in a txt file, created in order to backup the data and making therefore possible for write.txt to have a backup. The .txt is called after the actual time when the function is called.
Everytime it's called, it creates a new file.
Future rework: delete the older backups, keep a maximum number of files, where the maximum is represented by X: it can be defined by the user, by default should be a value of 5 or 10. - Given an already existing txt file written by the previous "writingFile" method, it loads the data retrieved from the txt file into the YEARS ArrayList.
-
Given a folder with different txt files, each named in the format YYYY_MM_DD_hh_mm_ss.txt, a list is created with all the files name.
The list is then reverse-sorted, and with the help of the list all the files, except for the first N (most recents), are deleted. - Given HashMap categoriesMap, writes CategoriesCFG file with CODE, DESCR entries.
- Given a txt file CATEGORIES, which consists of entries of the type CODE() DESCR(). Returns an HashMap (key: CODE , value: DESCR )
-
Given a YEARS ArrayList, the method iterates through it and saves all its data in a txt file, created in order to save the data and making therefore possible for the readingFile method to load the already existing data.
-
This class has static methods and attributes used without any instance for this class by all the others Classes.
- ANSI_COLOR_CODES
- Given a string, returns an integer from 0 to 11, or -1.
- KAE-SC logo, displayed on the boot-up.
- the main's possible choices.
- converts a double value to a string, cutting it to 2 or 1 decimal values
- returns true if the String is a valid double, false otherwise.
- returns true if the String is a valid integer, false otherwise.
- returns true if the String contains "comma" character, false otherwise.
- returns true if the String contains "dot" character, false otherwise.
- Given a category code, returns true if categoriesMap has no equal code to categoryCode, or returns false if categoriesMap has at least a code equal to categoryCode
- returns the string with the first letter capitalized
- returns the string with the first letter capitalized after lower case
- prints the cursor for the menu input choice (unused as of now)
-
This class has static methods used by the switch manager, these are the main features.
- Adds a Month Salary
- Given the year and the month, edits a salary income with a new value
- Adds an expense to a specific Month
- Given the year and the month, edits a salary income with a new value
- Prints the data related to all the Years. Depending on the flag 'detailsFlag', details about expenses will also be printed.
- Prints all the data related to a specific Year
- Loads from write.txt file (overwrites actual data)
- Saves current data into write.txt and it creates a backup file, for a maximum of 5 backups (through the FileHandler method deleteBackup)
- Displays stats for each month, giving a percentage representation for expenses and gains
- Displays expenses grouped by Categories, per month, ordered by amount
- Given an HashMap and the input entry, returns the HashMap with the new element added
- Given an HashMap, which is populated by reading CategoriesCFG.txt, all the entries CODE DESCRIPTION are displayed.
- Given the expense id, the year and the month, edits an expense with several options:
- Edit expense outcome
- Edit expense description
- Edit expense category
- Remove expense
- Given the year arraylist and a category in input,returns the same collection but filtered by expenses with the selected category.
- Given the year arraylist and a description in input, returns the same collection but filtered by expenses which contains the description in input in their descriptions.
- Given an ArrayList, displays all the data related to all the Years but with a different format from printAll
- TXT file in which are stored the categories Code and Description
- GenericException
GenericException description
-
Has an ArrayList for every year (12 months, key (1 aka January, 2 February and so on...), value))
Has a method (monthToInt) used to convert String month names to Integers (which returns -1 if the month name is not valid), and a menù method to show all the options.
The above methods are both static, as they are called inside the main.
The menù contains several options:- Add Salary
Given a month name (e.g. November), an amount and an Year, through the Utils.MonthToInt method, the main allocates the Salary in its position in the HashMap(e.g. November = 11): If the inserted month already exists (the place into the HashMap is already assigned), it will be resetted with the new parameters.
In other words, if a month needs to be erased, this functionality can be used in order to reinitialize it. - Edit Salary
Given a month and an year, the income is updated with the new value. - Add Expense
Given an amount, a description,, a category, a month and an year, the expense is added to the Salary which has the same month and year. - Edit Expense
Given a month name (and a Year), followed by an ID (visible in the Print), the specific expense can be edited or deleted.
To snchronize all the data, after the remove it follows a write into the file, to save the occured changes. - Print all the months for all the registered years, just listing gains in total and for each year.
If a month or a year has a negative ingain, a warning is displayed. - Print all the months for all the registered years, also giving data for expenses and gains in total and for each year.
If a month or a year has a negative ingain, a warning is displayed. - Print all the months for all the registered years, filtering by the input Category.
- Print all the months for all the registered years, filtering by the given words: each expense which contains the input in the description is displayed.
- Print all the months for the selected year.
If a month or the year has a negative ingain, a warning is displayed. - Loads from write.txt file (overwrites actual data)
Read a txt file importing all the previously saved elements.
Saves actual data into write.txt (overwritten each time) and also creates a unique backup file each time, to minimize data loss risk.
When saving the backup, it also checks if there are already more than seven backups: if that's the case, the older are deleted.
Writes all the data in a txt file, in order to retrieve those through the readingFile method. - Show stats for each month, giving a percentage representation for expenses and gains
Displays the percentages associated with each month, in terms of gain and expenses, through the showStats method. - Displays stats for each month, giving a percentage representation for expenses and gains.
- Expenses per month, grouped by Categories and ordered by amount
Displays expenses grouped by categories ordering for amount, for each month. - Expenses per month, grouped by Categories and ordered by amount
Displays expenses grouped by categories ordering for amount, for each year. - Adds a category to the CategoriesCFG.txt file, which is used to store the categories.
- Display all the categories stored in the CategoriesCFG.txt file.
- Add Salary