Setting up
Prerequisites
-
JDK 11 or later
-
IntelliJ IDE
Importing the project into IntelliJ
-
Open IntelliJ (if you are not in the welcome screen, click
File>Close Projectto close the existing project dialog first) -
Set up the correct JDK version
-
Click
Configure>Project Defaults>Project Structure -
If JDK 11 is listed in the drop down, select it. If it is not, click
New…and select the directory where you installed JDK 11 -
Click
OK
-
-
Click
Import Project -
Locate the project directory and click
OK -
Select
Create project from existing sourcesand clickNext -
Rename the project if you want. Click
Next -
Ensure that your src folder is checked. Keep clicking
Next -
Click
Finish
Design
AddressBook saves data in a plain text file, one line for each person, in the format NAME p/PHONE e/EMAIL.
Here is an example:
John Doe p/98765432 e/johnd@gmail.com Jane Doe p/12346758 e/jane@gmail.com
All person data are loaded to memory at start up and written to the file after any command that mutates data.
In-memory data are held in a ArrayList<String[]> where each String[] object represents a person.
Testing
Windows
-
Open a DOS window in the
testfolder -
Run the
runtests.batscript -
If the script reports that there is no difference between
ACTUAL.TXTandEXPECTED.TXT, the test has passed
Mac/Unix/Linux
-
Open a terminal window in the
testfolder -
Run the
runtests.shscript -
If the script reports that there is no difference between
ACTUAL.TXTandEXPECTED.TXT, the test has passed
Troubleshooting
-
Problem: How do I examine the exact differences between
ACTUAL.TXTandEXPECTED.TXT?
Solution: You can use a diff/merge tool with a GUI e.g. WinMerge (on Windows). -
Problem: The two files look exactly the same, but the test script reports they are different.
Solution: This can happen because the line endings used by Windows is different from Unix-based OSes. Convert theACTUAL.TXTto the format used by your OS using some utility. -
Problem: Test fails during the very first time.
Solution: The output of the very first test run could be slightly different because the program creates a new storage file. Tests should pass from the 2nd run onwards.