Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ What's different from AddressBook-Level1:
* Support for storing address (`a/`) and tags (`t/`)
* Support for marking a contact detail as 'private' (`pa/`) (`pe/`) (`pp/`)
* View details of a person (`view` : shows non-private details), (`viewall` : shows all details)
* Allows user to write and save notes
* Supports viewing of saved notes

== Viewing help : `help`

Expand Down
Binary file not shown.
23 changes: 18 additions & 5 deletions src/seedu/addressbook/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Main {

/** Version info of the program. */
public static final String VERSION = "AddressBook Level 2 - Version 1.0";

private static String[] NOTE;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably have Notes as its own class instead of being in Main.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. A proper design would require Note to be a class which associates itself to a Person.

private TextUi ui;
private StorageFile storage;
private AddressBook addressBook;
Expand Down Expand Up @@ -83,10 +83,18 @@ private void runCommandLoopUntilExitCommand() {
Command command;
do {
String userCommandText = ui.getUserCommand();
command = new Parser().parseCommand(userCommandText);
CommandResult result = executeCommand(command);
recordResult(result);
ui.showResultToUser(result);
if (userCommandText.equals("note"))
NOTE = TextUi.notes();

if (userCommandText.equals("viewnote"))
TextUi.viewNotes();

command = new Parser().parseCommand(userCommandText);
CommandResult result = executeCommand(command);
recordResult(result);
ui.showResultToUser(result);



} while (!ExitCommand.isExit(command));
}
Expand Down Expand Up @@ -127,5 +135,10 @@ private StorageFile initializeStorage(String[] launchArgs) throws InvalidStorage
return isStorageFileSpecifiedByUser ? new StorageFile(launchArgs[0]) : new StorageFile();
}

public static String[] getnote(){

return NOTE;
}


}
4 changes: 4 additions & 0 deletions src/seedu/addressbook/data/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import seedu.addressbook.data.person.UniquePersonList.DuplicatePersonException;
import seedu.addressbook.data.person.UniquePersonList.PersonNotFoundException;

import java.util.Scanner;

/**
* Represents the entire address book. Contains the data of the address book.
*/
Expand Down Expand Up @@ -74,4 +76,6 @@ public boolean equals(Object other) {
|| (other instanceof AddressBook // instanceof handles nulls
&& this.allPersons.equals(((AddressBook) other).allPersons));
}


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably these whitespaces are not needed.

}
3 changes: 3 additions & 0 deletions src/seedu/addressbook/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,7 @@ private Command prepareFind(String args) {
}





}
31 changes: 31 additions & 0 deletions src/seedu/addressbook/ui/TextUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import static seedu.addressbook.common.Messages.MESSAGE_USING_STORAGE_FILE;
import static seedu.addressbook.common.Messages.MESSAGE_WELCOME;

import java.awt.geom.NoninvertibleTransformException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;

import seedu.addressbook.Main;
import seedu.addressbook.commands.CommandResult;
import seedu.addressbook.data.person.ReadOnlyPerson;

Expand Down Expand Up @@ -169,4 +171,33 @@ private static String getIndexedListItem(int visibleIndex, String listItem) {
return String.format(MESSAGE_INDEXED_LIST_ITEM, visibleIndex, listItem);
}

public static String[] notes() {
Scanner input = new Scanner(System.in);
System.out.println("How many items are there?");
int number = input.nextInt();
int counter;
String[] instruct = new String[number+1];
for (counter = 0; counter <= number; counter++) {
String str = input.nextLine();
if (str.equals("done")) {
break;
} else {
instruct[counter] = str;
}
}
System.out.println("Noted down");

return instruct;
}

public static void viewNotes(){
String[] result = Main.getnote();
for(String str: result){
System.out.println(str);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly note that this method "notes" is failing SE principles. Ways to improve would include following SLAP and SRP (printing, input, etc. all happening at the same place right now).


}


}