Developer Guide
Acknowledgements
The format of our developer guide is adapted from SE-EDU AddressBook Level 3. Code used in this project is reused and adapted from our team’s individual project during this module.
Design
All .puml
files used to create the UML diagrams can be found in our diagrams folder.
Architecture
Figure 1: Architecture Diagram for Pet Tracker
The Architecture Diagram given above explains the high-level design of the App. Given below is a quick overview of each component.
Main components of the architecture
Main
is responsible for,
- At app launch: Initializes the components in the correct sequence, and connects them up with each other.
- At shut down: Shuts down the components and invokes cleanup methods where necessary.
The rest of the App consists of four components.
Ui
: The UI of the App.Parser
: Parses the user input.Command
: The command executor.Data
: Holds the data of the App in memory.Storage
: Reads data from, and writes data to, the hard disk.
Implementations
Ui Class
The Ui class is represented by the image below. The Ui class handles user input and
displaying of the relevant information including error messages for the program. In the diagram below,
VariousCommands
represents different commands that may call the Ui Class.
The Main
class will call getUserInput()
to read in user input. Commands may then
call the methods to print relevant outputs.
Figure 2: Class Diagram for Ui
Exit Command
The ExitCommand
inherits its properties from the abstract Command
class.
The command to exit the program is exit
.
If ‘exit’ is called, the program prints the exit message and terminates the program.
This is how the ExitCommand works:
-
The
main()
method in Main callsrun()
in Main. -
run()
will callrunCommandTillExit()
. -
The
ui
reads the user’s input to retrieve the command viaui.getUserInput()
and parses it throughcommandParser.parseCommand()
. - Within the
commandParser.parseCommand()
, some functions are also internally called.newCommand()
is called to identify the String receivedparseKeyword()
is called to split the command from the parameters.
-
A new
ExitCommand()
is called. -
ExitCommand
is returned to parseCommand(). -
ExitCommand
is returned to main(). -
The Exit Command is now executed via
command.execute()
. -
runCommandTillExit()
will now callcommand.isExit()
which returnstrue
. -
The loop is now broken and ui will call
ui.showEndingMessage()
. - The program will now exit.
Figure 3: Sequence Diagram for Bye Command
List Pet Command
The ListPetCommand
inherits its properties from the abstract Command
class.
The command to list all pets currently available is list
. When called, the program prints all the names and statistics of the existing pets (if any), followed by the number of pets currently in the list.
This is how the ListPetCommand works:
-
The
main()
method callsui.getUserInput()
fromui
. The user’s command is parsed throughcommandParser.parseCommand()
. -
Within
commandParser.parseCommand()
,newCommand()
will identify the command received (list
). -
ListPetCommand()
calls thelist()
method from thePetList
class. -
PetList.list()
then iterates through all pets inpetList
, callingpet.getPetName()
,pet.getPetType()
,pet.getAge()
andpet.getWeight()
each iteration, then prints the number of pets. -
The loop is now broken to return
ListPetCommand
toparseCommand()
. -
ListPetCommand
is returned tomain()
. -
The program is now ready to receive another command.
Figure 4: Sequence Diagram for List Pet Command
Add Pet Stat Feature
The add pet stat mechanism is facilitated by the Pet
class. It is stored internally as a petList
created under the PetList
class. Additionally, it implements the following operations:
Pet#addStat()
- Checks which type of stat the user wants to add (i.e. weight, age, pet type)Pet#setAge()
- Sets the age of the petPet#setPetType()
- Sets the type of the pet (e.g. Dog, Cat, Parrot)Pet#setWeight()
- Sets the weight of the pet
These operations are exposed in the PetList
class as PetList#addStat()
and AddStatCommand
class as AddStatCommand#execute()
.
Figure 5: Class Diagram for Add Pet Stat Feature
Given below is an example usage scenario and how the add pet stat mechanism behaves.
Step 1. After the user launches the application and added a pet named “Bob”, a Pet
object will be initialised and saved in the petList
.
Figure 6: Object Diagram for Add Pet Stat Feature After Step 1
Step 2. The user executes add-stat Bob weight 5
command to add a weight stat of 5kg in the Pet
object. After parsing, the add-stat
command calls AddStatCommand#execute()
then PetList#addStat()
, causing the Pet
object’s weight
variable to be modified and saved.
Figure 7: Object Diagram for Add Pet Stat Feature After Step 2
Remove Pet Stat Command
The RemoveStatCommand
class inherits its properties from the abstract Command
class.
This class is executed whenever the remove-stat <pet name> <stat name>
command is called by the user. The intended functionality of this command is to remove the <stat name>
from the pet with name <pet name>
.
It works like this:
-
The
main()
method callsui.getUserInput()
fromui
. The user’s command is parsed throughcommandParser.parseCommand()
. -
Within
commandParser.parseCommand()
,newCommand()
will identify the command received (remove-stat
). -
RemoveStatCommand.parseArgs()
separates the arguments into the pet name and stat name. -
RemoveStatCommand.execute()
callsPetList.removeStat()
with the pet name and stat name, and callsui.removeStatCommandMessage()
to send output to the user. -
PetList.removeStat()
uses its internalfind()
method to find the corresponding Pet object, and callsPet.removeStat()
on that object. -
Pet.removeStat()
uses a switch statement on the stat name to identify the proper method to call: eithersetPetType("")
,setAge("")
, orsetWeight("")
. If the stat name does not match any of those, it prints out an error message. -
Pet.removeStat()
,PetList.removeStat()
, andRemoveStatCommand
all return, allowing the program to receive another command.
This feature was implemented like this in order to maximize use of the OOP paradigm.
Figure 8: Sequence Diagram for Remove Pet Stat Command
Command Parser
The CommandParser
class is responsible for parsing the user’s input into a Command
object. It does this by splitting
the input into its keyword and arguments using Java’s Regex Matcher, and then using a switch statement to identify the
keyword and invoke the respective argument parser.
How the Command Parser works:
- The user’s input is passed into the
parseCommand()
method. - The input is split into its keyword and arguments using Java’s Regex Matcher.
- The keyword is used to identify the command, and the arguments are passed into the respective argument parser.
- The argument parser checks the validity of the arguments, and returns a
Command
object if the arguments are valid.
Figure 9: Sequence Diagram for Add-Stat Command
Appendix: Requirements
Product scope
Target user profile
Pet Tracker is developed for people who take care of multiple pets (Pet Hotels/Pet Sitters) who prefer to use CLI applications to quickly track and update details relating to their pet.
Value proposition
Pet Tracker will allow for fast-typing users to save more time when keeping track of pets. Users will be able to quickly update any of their existing pet details or add in new ones, while being able to review all current information of all the pets they have at a glance. In addition, Pet Tracker allows users to add tasks for errands that even has a reminder feature so that users will be reminded to do the tasks that are due on the day itself.
User Stories
Version | As a … | I want to … | So that I can … |
---|---|---|---|
v1.0 | basic user | add new pets | track more pets |
v1.0 | basic user | record my pet’s weight | track if the weight is healthy |
v1.0 | basic user | record my pet’s age | track how old my pet is |
v1.0 | basic user | remove a pet from my list | de-clutter the pet-list from pets I no longer take care of |
v1.0 | large-scale user | see basic info on all my pets in one place | get an overview of all my pets |
v2.0 | basic user | save my pet list | save my pet list data when i close the program |
v2.0 | basic user | load my saved pet list | resume where i left off previously |
v2.0 | basic user | add task | remind myself to carry out a task |
v2.0 | basic user | mark uncompleted tasks as done | check off tasks that i complete |
v2.0 | basic user | unmark completed tasks | uncheck off tasks that i did not complete |
v2.0 | basic user | see all my tasks in one place | get an overview of all my tasks |
v2.0 | basic user | edit my pet information | modify my pet information when i need to update it |
v2.0 | basic user | edit my task information | modify my task information when i need to update it |
v2.0 | basic user | get a schedule of what time tasks must be done | better meet my pets need by carrying out the task |
v2.0 | forgetful user | receive reminders about what task is due today | complete tasks that are due today |
Non-Functional Requirements
- Pet Tracker should work on mainstream OS as long as Java 11 is installed.
- User with higher typing speed compared to an average person should be able to accomplish most tasks faster than using the mouse.
- Does not require internet to run
- Should be able to hold up to 1000 pets/tasks without any noticeable sluggishness in performance
Glossary
- Mainstream OS - Windows / MacOS / Linux
- Pet - Domestic/Tamed animal
- Task - A task to be carried out (e.g. Feeding a pet)
- Stat - Statistic of a pet such as Pet Type(Dog / Cat), Age or Weight
- Value - Result of the statistic (e.g. 5,10,15)
- VariousCommands - Commands in general, non-specific
Instructions for manual testing
Launch and Shutdown
- Initial Launch
- Ensure that you have Java 11 or above installed.
- Download the latest version of
Pet Tracker
from here. - Launch a terminal in the folder that the jar file is located in
- Run the command
java -jar pettracker.jar
Expected Outcome: The program should run in the terminal.
- Shutdown
- Type
exit
to quit the application
- Type
Expected Outcome: Pet Tracker will terminate and display Goodbye! See you soon.
Testing Storage
- Saving and Loading Data
- Launch the application and add pets/tasks
- All changes will be automatically saved to the output file.
- Upon terminating and re-launching the application, Pet Tracker will load the files from
the
output
folder named aspetoutput.txt
andtaskoutput.txt
Expected Outcome: Pet Tracker will successfully load both data files and restore the state of the application as if it was never closed.
- Missing Data File
- Delete the
petoutput.txt
ortaskoutput.txt
file in theoutput
folder - In the event that the data file is missing, Pet Tracker will not see the former state of the application.
- Pet Tracker will run as if it is the first time launching this program.
- Delete the
Expected Outcome: Pet Tracker runs with an empty data file.
- Corrupted Data File
- Change pet age to be a non integer, or delete some pipes in the
petoutput.txt
ortaskoutput.txt
file. - If the data files are corrupted, PetTracker will print out errors and may not be able to successfully import in previous states.
- Change pet age to be a non integer, or delete some pipes in the
Expected Outcome: Pet Tracker may start with a partially loaded state.
Extras
- Users should not try to corrupt the data output file by changing the data directly.