SysLib is a CLI Library Management software for system librarians.
From viewing, adding, searching, editing, deleting and saving, SysLib provides all the features needed to manage library resources and events.
View the code I contributed via the tp Code Dashboard link here.
Details:
1. Command and Delete Command for resources
Main classes and methods implemented:
Command
classDeleteCommand
classexecute()
in Command
classparseArugment()
, getMatch
and checkMatch
in Command
classvalidate()
and checkDuplicate
in Command
classgetReason()
in Command
classparseInt()
in Command
classImplemented a class Command
which is an abstract class to execute()
each command
User keys in a command followed by its arguments using “/”.
For each command they have their own required arguments,
so this list, args
, differs for each command,
but the implementation is the same.
Thus parseArgument()
function will be called to first to get these arguments,
which loops through the list of args
that the command requires,
then getMatch()
is called to check if the arguments exist in the user input,
which calls checkMatch()
to ensure no issues with “/” in arguments.
After validate()
is called to verify the user input against the arguments received,
this then calls checkDuplicate()
to check for duplicate calls of the same argument.
At the end, validate()
checks for additional random variables/commands.
If there is, getReason()
will be called to verify the reason for error to give more
informative feedback.
If the additional command/variable resemble an argument, a suggested argument will be given.
parseInt()
is by some commands to check for an input of a valid integer.
DeleteCommand
class is an implementation of Command
that get takes in the id of the resource
to be deleted, the id is parsed through the parseInt()
function
2. Parser and SuggestParser Class
Parser
class includes:
commandProcessor
hashmapeventList
and resourceList
ArrayListprocessUserResponse
functionremoveFirstWord
functionsuggest
in SuggestParser
classcommandProcessor
stores the String variable of the command as a key and the Command variable as the value.
Thus by using removeFirstWord
and taking this word, we can compare it to the keys in commandProcessor
to get the right command to execute.
eventList
and resourceList
are the ArrayList to store the event
and resource
that is currently in the database.
It can be used by other commands to add/edit/delete informations.
processUserResponse
makes use of the commandProcessor
and removeFirstWord
to call the right command.
If no valid command is found, the suggest
function in SuggestParser
will be called to try to find the nearest valid command that the user may be trying to call.
3. EventAdd, EventList, EventDelete Command for events
Using the eventList
in Parser to store events, we can use these functions below to manipulate events:
EventAdd
EventList
EventDelete
EventAdd
takes in title, date and description(optional) of the event and store this in the eventList.
This event is then stored at the index where it fits chronologically(earlier dates first).
EventList
list out all the existing events in chronological order.
EventDelete
deletes the event based on the given index.