-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Massive improvement to source model #69
Conversation
Merge from Main 8/3/2019
Source model can now be tested with three basic functions: add - which adds a new source to the database delete - which deletes a source by index list - which lists all the sources currently in the database Database will also load saved sources and automatically save when the exit command is entered Added a user menu for development purposes You can now enter an operation mode to select which app to test: 1 - for the standard address book 4 2 - to test the new model
The abstraction for the individual items in the source object have been added but was not included in this latest version of the model. As it is, the extra abstraction feels unnecessary since it is just an object with a string inside. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusts the database model to handle sources with some basic functionality. Somewhat unsure what SourceItem* objects achieve other than add complexity, but code is functional.
|
||
switch (input) { | ||
case "1": | ||
System.out.println("Starting Addressbook 4."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should extract these strings out as constants and put them at the top of the file
+ "list\n" | ||
+ "exit\n"); | ||
|
||
boolean loopCondition = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe name it more descriptively than loopCondition?
+ "exit\n"); | ||
|
||
boolean loopCondition = true; | ||
while (loopCondition == true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the == true
part is unnecessary
@@ -29,6 +33,9 @@ public void deleteSourceAtIndex (int index) { | |||
public void deleteAllSources () { | |||
database.clear(); | |||
} | |||
public Source getSourceAtIndex (int index) { | |||
return database.get(index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not handling IndexOutOfBoundsException!!!
src/main/java/seedu/address/sourcemodel/SourceDatabaseCoordinationCenter.java
Outdated
Show resolved
Hide resolved
case "add": | ||
// Check size of array (in case user enters "add" and nothing else) | ||
if (orderSplit.length < 2) { | ||
System.out.println("Invalid command parameters.\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor string constants
Source model can now be tested with three basic functions:
add - which adds a new source to the database
delete - which deletes a source by index
list - which lists all the sources currently in the database
Database will also load saved sources and automatically save when the exit command is entered
Added a user menu for development purposes
You can now enter an operation mode to select which app to test:
1 - for the standard address book 4
2 - to test the new model
#68