forked from nus-cs2113-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from yentheng0110/master
Implement the add and list commands
- Loading branch information
Showing
4 changed files
with
128 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,55 @@ | ||
package BookBob; | ||
|
||
import BookBob.entity.Records; | ||
import BookBob.functions.CommandHandler; | ||
import BookBob.functions.SaveAndRetrieve; | ||
import java.util.Scanner; | ||
|
||
public class Main { | ||
/** | ||
* Main entry-point for the java.duke.Duke application. | ||
*/ | ||
|
||
public static void main(String[] args) { | ||
String logo = " ____ _ \n" | ||
+ "| _ \\ _ _| | _____ \n" | ||
+ "| | | | | | | |/ / _ \\\n" | ||
+ "| |_| | |_| | < __/\n" | ||
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||
System.out.println("Hello from\n" + logo); | ||
System.out.println("What is your name?"); | ||
System.out.println("Welcome to BookBob, Dr. Bob!"); | ||
|
||
Scanner in = new Scanner(System.in); | ||
System.out.println("Hello " + in.nextLine()); | ||
Records records = new Records(); | ||
SaveAndRetrieve.initFile(records); | ||
CommandHandler commandHandler = new CommandHandler(); | ||
|
||
while (true) { | ||
String input = in.nextLine(); | ||
String[] inputArr = input.split(" ", 2); | ||
String command = inputArr[0]; | ||
|
||
switch (command) { | ||
case "exit": | ||
commandHandler.exit(input); | ||
break; | ||
|
||
case "add": | ||
commandHandler.add(input, records); | ||
break; | ||
|
||
case "list": | ||
commandHandler.list(records); | ||
break; | ||
|
||
case "delete": | ||
if (inputArr.length > 1) { | ||
String NRIC = inputArr[1].trim(); | ||
commandHandler.delete(NRIC, records); | ||
} else { | ||
System.out.println("Please specify an NRIC to delete."); | ||
} | ||
break; | ||
|
||
case "help": | ||
commandHandler.help(); | ||
break; | ||
|
||
default: | ||
System.out.println("Unknown command. Type 'help' for a list of commands."); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters