From f06fd8f379ae7c9ab08a6d5126afb788e5aa51ed Mon Sep 17 00:00:00 2001 From: Quinn Date: Mon, 11 Feb 2019 13:52:12 +0800 Subject: [PATCH 1/2] W5T0801-ZhaoJunRu Warning Message added --- src/seedu/addressbook/commands/ClearCommand.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/seedu/addressbook/commands/ClearCommand.java b/src/seedu/addressbook/commands/ClearCommand.java index 6f88f8e13..f53091342 100644 --- a/src/seedu/addressbook/commands/ClearCommand.java +++ b/src/seedu/addressbook/commands/ClearCommand.java @@ -1,4 +1,5 @@ package seedu.addressbook.commands; +import java.util.*; /** * Clears the address book. @@ -8,12 +9,21 @@ public class ClearCommand extends Command { public static final String COMMAND_WORD = "clear"; public static final String MESSAGE_USAGE = "Clears address book permanently.\n" + "Example: " + COMMAND_WORD; - public static final String MESSAGE_SUCCESS = "Address book has been cleared!"; + public static final String MESSAGE_FAILURE = "Exiting clear function"; + @Override public CommandResult execute() { - addressBook.clear(); - return new CommandResult(MESSAGE_SUCCESS); + System.out.println("Confirm to clear the entire address book? YES to continue"); + Scanner scanner = new Scanner(System.in); + String next = scanner.next(); + if (next.equals("YES")) { + addressBook.clear(); + return new CommandResult(MESSAGE_SUCCESS); + } + + return new CommandResult(MESSAGE_FAILURE); } } + From 1b7316d042198bb1fab1431a11e43ce1d04f795a Mon Sep 17 00:00:00 2001 From: Quinn Date: Mon, 11 Feb 2019 14:21:18 +0800 Subject: [PATCH 2/2] user-guide added --- docs/UserGuide.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index 4abb17e3e..0109dc654 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -153,7 +153,10 @@ Views all details of the 1st person in the results of the `find` command. == Clearing all entries : `clear` +Warning message for clearing all data +Key in "YES" to continue Clears all entries from the address book. + +Any key to exit clear function Format: `clear` == Exiting the program : `exit`