Project: Tourist-Book
Tourist-Book is a desktop address book application used for teaching Software Engineering principles. The user interacts with it using a CLI, and it has a GUI created with JavaFX.
Code contributed: [Functional code] [Test code]
Useful contact numbers in Singapore
Display a list of useful contact numbers by clicking on Help → Useful Contacts
or
Display a list of useful contact numbers by using the CLI.
Format: emergency
or sos
or
Using the shortcut key.
Format: F2
End of Extract
Justification
Since the project is targeted at tourists who are visiting Singapore, it is important for them to have easy access to a list of emergency numbers in Singapore for easy reference should the need arises. The list of numbers include hospitals and ambulance hotlines.
Emergency/Useful Contacts
The Emergency/Useful Contacts function allows the user to quickly view a pre-defined list of contact numbers.
The underlying implementation is by invoking the browser window and changing the information it displays to the user.
The Emergency/Useful Contacts function is a CL command that can be invoked by the user.
The following is the class diagram of Emergency/Useful Contacts.
The following is the sequence diagram of the Emergency/Useful contacts command.
emergency
or sos
command
Both commands will invoke the same contacts page.
Design Considerations
Aspect: Implementation of emergency
/ sos
Alternative 1 (current choice) Making use of the browser window to display the contacts information.
Pros: Easy to implement.
Cons: HTML file is hard to edit / cannot be edited.
Alternative 2: Create a new UI element (e.g. Text panel) and display when called.
Pros: Able to display contacts within the app itself.
Cons: Tedious to implement, GUI testing has added complexity.
Aspect: User experience for emergency
/ sos
Alternative 1 (current choice) Have 2 dedicated commands and quick key button (F2).
Pros: Allows user a more flexible choice of invoking the contacts list.
Cons: Takes up a quick key combination which can be used to invoke other shortcuts.
End of Extract
Locating places by name or tag: find
or fd
Finds places whose names or tags contain any of the given keywords.
Format: find [PREFIX]KEYWORD [MORE_KEYWORDS]
or fd [PREFIX]KEYWORD [MORE_KEYWORDS]
Examples:
-
find n/Singapore
ReturnsSingapore Zoo
andSingapore Flyer
-
fd n/Singapore Sands Botanic
Returns any place having namesSingapore
,Sands
, orBotanic
-
find t/attractions
Returns a list of places tagged asattractions
-
fd t/onestar
Returns a list of places tagged asonestar
End of Extract
Justification
Since the project is implemented with Places and using tags to describe a place (e.g. onestar), it is required for users to be able to search the list either by name or by the tag that the place is tagged to for easy reference. In addition, users may want to search for more than one name or tag at the same time as well.
Editing the Find Command to search by Name and Tag
The Find command is able to search the Tourist Book by Name of the place of by the Tags of the place.
The user is able to invoke the command with find
or fd
, followed by a PREFIX.
Prefixes
* n/
: prefix for searching by Name.
* t/
: prefix for searching by Tag.
Design Considerations
Aspect: Implementation of find
Alternative 1 (current choice) Enhancing the find command to find by name and tags.
Pros: User does not need to remember many commands.
Cons: User has to use prefixes to search for name or tags.
Alternative 2: Create a new command to search by other details.
Pros: Relatively easier to implement.
Cons: Tedious to test, not very intuitive for the user.
Aspect: User experience for find
Alternative 1 (current choice) Have 1 command and 2 dedicated prefixes.
Pros: Allows user a more flexible choice of find through the contacts list.
Cons: Can only search for one type of attribute at any time.
End of Extract
Tourist book save files can now be backed-up
Backup a copy of your data to the same folder of the save file.
Format: backup
+
Running the command again if you already have a previous backup will overwrite the previous backup file! |
End of Extract
Justification
This is to allow users to be able to backup their data. In the event their main file is corrupted or lost, there is still a backup file.
Implementation
Start of Extract [from: Developer Guide]
Storage
component
Do take a look at the Design: Storage Component section before attempting to modify the Storage component.
|
-
Add a new method
backupAddressBook(ReadOnlyAddressBook)
, so that the address book can be saved in a fixed temporary location.
End of Extract
Tourist Book save files are now exportable to .csv format
Export your data to .csv file format for printing purposes.
Format: export
End of Extract
Justification
As described in the User Stories, this is to allow users to be able to save and print out their files easily so that they are still able to know the information about a place without being connected to a computer.
Export
The ExportCommand
extends the Command
class. It allows users to export the current Address Book data
into a CSV file.
The class diagram of the command is shown below:
Figure 3.9A - Class Diagram of ExportCommand
From Figure 3.9A, the ExportCommand depends on java.io
to carry out the file IO operations to create the CSV file.
It also depends on the Model
class and Place
package in order to extract the required information to export.
The sequence diagram of the command is shown below:
Figure 3.9B - Sequence Diagram of ExportCommand
Explanation of Figure 3.9B:
-
The
execute("export")
command is called on theLogicManager
. -
LogicManager
calls theparse
method onAddressBookParser
. -
The
parse
method creates a newExportCommand
which returns anExportCommand
,e
, all the way back toLogicManager
. -
LogicManager
calls theexecute()
method one
, anExportCommand
. -
ExportCommand
obtains thePlaceList
from theModel
. -
ExportCommand
checks if an exported file exists. If the file exists, it will delete the file. -
ExportCommand
generates the exported file through a series of self calls and generates a newCommandResult
,result
. -
The
result
is returned to theLogicManager
which returns it back to theUI
.
Design Considerations
Aspect: Construction of Strings
Alternative 1 (current choice): Using StringBuilder
Pros: Able to easily construct the String
due to the mutability of StringBuilder
.
Cons: Dependency on the StringBuilder
class.
Alternative 2: Using String
only.
Pros: Reduced dependency on additional classes.
Cons: Constant re-assignment of resultant String
is required as it is not mutable.
Aspect: Generating Place Data
Alternative 1 (current choice): "Hard-code" the data to obtain from a ReadOnlyPlace
.
Pros: Code is executed at a faster rate.
Cons: Coupling is increased with ReadOnlyPlace
/Code is not adaptable if new fields are added to ReadOnlyPlace
.
Alternative 2: Generate place data according to the fields present in ReadOnlyPlace
.
Pros: Code is adaptable should new fields be added to ReadOnlyPlace
.
Cons: Additional processing overhead / Difficult and time-consuming to implement.
The implementation of the method is credited to Ryan Teo and
this issue.
End of Extract