Skip to content

Commit

Permalink
Merge pull request #30 from darrenangwx/branch-refactorPR
Browse files Browse the repository at this point in the history
Refactoring after PR merge
  • Loading branch information
darrenangwx authored Mar 14, 2023
2 parents 5f4b238 + ffb9193 commit 602a49c
Show file tree
Hide file tree
Showing 22 changed files with 182 additions and 169 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package commands.deadlinecommand;
package commands.deadline;

import entity.Deadline;
import manager.DeadlineManager;
Expand All @@ -10,6 +10,7 @@ public class AddDeadlineCommand extends commands.Command {

/**
* Creates an add deadline command that adds the deadline item being passed through.
*
* @param deadline the deadline to add to the list.
*/
public AddDeadlineCommand(Deadline deadline) {
Expand All @@ -18,6 +19,7 @@ public AddDeadlineCommand(Deadline deadline) {

/**
* Executes the add deadline command.
*
* @param ui manages user input.
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package commands.deadlinecommand;
package commands.deadline;

import manager.DeadlineManager;
import ui.TextUi;
Expand All @@ -9,6 +9,7 @@ public class DeleteDeadlineCommand extends commands.Command {

/**
* Creates a delete deadline command that deletes the deadline item of the index being passed through.
*
* @param index the index of the deadline item to delete.
*/
public DeleteDeadlineCommand(int index) {
Expand All @@ -17,6 +18,7 @@ public DeleteDeadlineCommand(int index) {

/**
* Executes the delete deadline command.
*
* @param ui manages user input.
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package commands.deadlinecommand;
package commands.deadline;

import manager.DeadlineManager;
import ui.TextUi;

public class ViewDeadlineCommand extends commands.Command {
public static final String COMMAND_WORD = "view_deadline";
public static final String COMMAND_WORD = "view_deadlines";

/**
* Executes the view deadline command.
*
* @param ui manages user input.
*/
@Override
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/commands/meeting/AddMeetingCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,25 @@


public class AddMeetingCommand extends Command {
public static final String COMMAND_WORD="add_meeting";
public static final String COMMAND_WORD = "add_meeting";
public static String time;
public static String issue;
public AddMeetingCommand(String time,String issue){
this.time=time;
this.issue=issue;

public AddMeetingCommand(String time, String issue) {
this.time = time;
this.issue = issue;
}

@Override
public boolean isExit() {
return false;
}

@Override
public void execute(TextUi ui) {
ui.printMessage(Messages.MESSAGE_ADD_MEETING);
Meeting m=new Meeting(this.time,this.issue);
ui.printMessage(Messages.MESSAGE_MEETING_ADDED);
Meeting m = new Meeting(this.time, this.issue);
MeetingManager.addMeeting(m);
ui.printMessage(issue+" at "+time);
ui.printMessage(issue + " at " + time);
}
}
8 changes: 4 additions & 4 deletions src/main/java/commands/meeting/DeleteMeetingCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public boolean isExit() {

@Override
public void execute(TextUi ui) {
boolean hasDelete=MeetingManager.deleteMeeting(issue);
if(hasDelete){
ui.printMessage(issue+" deleted");
} else{
boolean hasDelete = MeetingManager.deleteMeeting(issue);
if (hasDelete) {
ui.printMessage(issue + " deleted");
} else {
ui.printMessage("Sorry! There's no such meeting");
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/commands/meeting/ViewMeetingCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
import ui.TextUi;

public class ViewMeetingCommand extends Command {
public static final String COMMAND_WORD="view_meetings";
public static final String COMMAND_WORD = "view_meetings";

@Override
public boolean isExit() {
return false;
}

@Override
public void execute(TextUi ui) {
ui.printMessage(Messages.MESSAGE_VIEW_MEETINGS);
ui.printMessage(Messages.MESSAGE_MEETING_VIEW_LIST);
ui.printMessage(MeetingManager.printMeetings());
}
}
2 changes: 1 addition & 1 deletion src/main/java/commands/menu/AddDishCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class AddDishCommand extends Command {

public static final String ADD_DISH_COMMAND = "add_dish";
public static final String COMMAND_WORD = "add_dish";
private String dishName;
private Integer dishPrice;
private ArrayList<String> ingredientsList;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/commands/menu/DeleteDishCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class DeleteDishCommand extends Command {

public static final String DELETE_DISH_COMMAND = "delete_dish";
public static final String COMMAND_WORD = "delete_dish";
private int index;

public DeleteDishCommand(int index) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/commands/menu/ViewDishCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class ViewDishCommand extends Command {

public static final String VIEW_DISH_COMMAND = "view_dish";
public static final String COMMAND_WORD = "view_dish";

public ViewDishCommand() {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
package commands;
package commands.staff;

import commands.Command;
import entity.Staff;
import manager.StaffManager;
import ui.TextUi;

public class AddStaffCommand extends Command{
public class AddStaffCommand extends Command {
public static final String COMMAND_WORD = "add_staff";
private String name;
private String workingDay;
private String phoneNumber;
private String dateOfBirth;
public AddStaffCommand(String name, String workingDay, String phoneNumber, String dateOfBirth){

public AddStaffCommand(String name, String workingDay, String phoneNumber, String dateOfBirth) {
this.name = name;
this.workingDay = workingDay;
this.phoneNumber = phoneNumber;
this.dateOfBirth = dateOfBirth;
}

@Override
public void execute (TextUi ui){
public void execute(TextUi ui) {
Staff staff = new Staff(this.name, this.workingDay, this.phoneNumber, this.dateOfBirth);
StaffManager.addStaff(staff);
ui.printMessage(staff + " added!");
}

@Override
public boolean isExit (){
public boolean isExit() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package commands;
package commands.staff;

import commands.Command;
import manager.StaffManager;
import ui.TextUi;

public class DeleteStaffCommand extends Command {
public static final String COMMAND_WORD = "delete_staff";
private String staffName;

public DeleteStaffCommand(String staffName) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package commands;
package commands.staff;

import commands.Command;
import manager.StaffManager;
import ui.TextUi;

public class ViewStaffCommand extends Command {
public static final String COMMAND_WORD = "view_staff";

public ViewStaffCommand() {
}

Expand Down
96 changes: 42 additions & 54 deletions src/main/java/common/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,57 @@ public class Messages {
/**
* Messages for programs to print.
*/
public static final String MESSAGE_VALID_COMMAND_LIST =
"List of valid commands:\n" +
"GENERIC COMMANDS:\n%s\n"+
"MEETING COMMANDS:\n%s\n"+
"DEADLINE COMMANDS:\n%s\n"+
"RECIPE COMMANDS:\n%s\n"+
"WORKER COMMANDS:\n%s";
public static final String MESSAGE_GENERIC_COMMANDS =
"help - View list of commands\n" +
public static final String MESSAGE_VALID_COMMAND_LIST = "List of valid commands:\n" +
"GENERIC COMMANDS:\n%s\n" +
"MEETING COMMANDS:\n%s\n" +
"DEADLINE COMMANDS:\n%s\n" +
"MENU COMMANDS:\n%s\n" +
"STAFF COMMANDS:\n%s";
public static final String MESSAGE_GENERIC_COMMANDS = "help - View list of commands\n" +
"exit - exits the program\n";
public static final String MESSAGE_MEETING_COMMANDS =
"add_meeting n/<name> t/<time>\n" +
public static final String MESSAGE_MEETING_COMMANDS = "add_meeting n/<name> t/<time>\n" +
"delete_meeting n/<meeting>\n" +
"view_meetings\n";
public static final String MESSAGE_DEADLINE_COMMANDS =
"add_deadline n/<name> t/<time>\n" +
"delete_deadline n/<name>\n" +
public static final String MESSAGE_DEADLINE_COMMANDS = "add_deadline n/<name> t/<time>\n" +
"delete_deadline <integer>\n" +
"view_deadlines\n";
public static final String MESSAGE_RECIPE_COMMANDS =
"add_recipe n/<name>\n" +
"delete_recipe n/<name>\n" +
"view_recipe\n";
public static final String MESSAGE_WORKER_COMMANDS =
"add_worker n/<name> w/<working day> d/<date of birth> p/<phone>\n" +
"delete_worker n/<name>\n" +
"view_workers\n";
public static final String MESSAGE_RECIPE_COMMANDS = "add_dish\n" +
"delete_dish <integer>\n" +
"view_dish\n";
public static final String MESSAGE_WORKER_COMMANDS = "add_staff <name> <working day> <phone> <date of birth>\n" +
"delete_staff n/<name>\n" +
"view_staff\n";
public static final String MESSAGE_COMMAND_EXIT = "Thank you for using DinerDirector!";
public static final String MESSAGE_ADD_MEETING="Got it! You have successfully added a meeting:";
public static final String MESSAGE_VIEW_MEETINGS="Meeting list:";
public static final String MESSAGE_MISSING_MEETING_PARAM = "Missing meeting parameter!";
public static final String MESSAGE_EXCESS_MEETING_PARAM = "You cannot have multiple name/time for your meeting!";
public static final String MESSAGE_EXCESS_VIEW_PARAM = "Excess input detected! Please only type \"view_meetings\".";

public static final String MESSAGE_DEADLINE_ADDED = "Got it! This deadline has been successfully added.\n";
public static final String MESSAGE_DEADLINE_EMPTY_LIST = "Your deadline list is empty!";
public static final String MESSAGE_DEADLINE_VIEW_LIST = "Here are the tasks in your list:";
public static final String MESSAGE_DEADLINE_REMOVED = "Noted. I've removed this task:\n";
public static final String MESSAGE_NUMBER_OF_DEADLINES = "\nNow you have %d tasks in the list.";
public static final String MESSAGE_MEETING_ADDED = "Got it! You have successfully added a meeting:";
public static final String MESSAGE_MEETING_VIEW_LIST = "Meeting list:";

public static final String ERROR_ADD_STAFF_COMMAND = "Insufficient information when adding a staff";
/**
* Errors for programs to print.
*/
public static final String ERROR_COMMAND_INVALID = "Please give a valid command! " +
"Type \"help\" for list of valid commands";

public static final String MESSAGE_DEADLINE_ADDED = "Got it! This deadline has been successfully added.\n";
public static final String MESSAGE_EMPTY_LIST = "Your deadline list is empty!";
public static final String MESSAGE_VIEW_LIST = "Here are the tasks in your list:";
public static final String MESSAGE_DEADLINE_REMOVED = "Noted. I've removed this task:\n";
public static final String MESSAGE_NUMBER_OF_DEADLINES = "\nNow you have %d tasks in the list.";

public static final String MESSAGE_INVALID_INDEX = "Invalid task index number!\n" +
"Enter \"view_deadline\" to check the index.";
public static final String MESSAGE_MISSING_INDEX = "Delete command must be followed by the index number!" +
"Enter \"view_deadline\" to check the index.";
public static final String MESSAGE_MISSING_PARAM = "Missing deadline parameter!";
public static final String MESSAGE_EXCESS_PARAM = "You cannot have multiple name/time for your deadline!";
public static final String MESSAGE_EXCESS_LIST_PARAM = "Excess input detected! Please only type \"view_deadline\".";
public static final String MESSAGE_FILE_CREATED = "Data file has been created. Your list will be saved.";
public static final String MESSAGE_FILE_LOADED = "Data file already exists. You list will be updated.";
public static final String MESSAGE_FILE_MISSING = "Data File Missing! Check if you have accidentally deleted it.";

public static final String MESSAGE_INVALID_INDEX_FOR_DISH_COMMAND = "Your index does not contain a valid dish!";
public static final String MESSAGE_NOT_A_VALID_INTEGER_COMMAND = "Your index has to be an integer!";
public static final String MESSAGE_BLANK_DISH_NAME_COMMAND = "Name of dish cannot be empty!";
public static final String MESSAGE_NEGATIVE_PRICE_COMMAND = "Price of dish cannot be negative!";
public static final String MESSAGE_INGREDIENT_LIST_CANNOT_BE_EMPTY = "Ingredient list cannot be empty!";

public static final String MESSAGE_EMPTY_INDEX_COMMAND = "Index cannot be empty!";
public static final String ERROR_DEADLINE_INVALID_INDEX = "Invalid task index number!\n" +
"Enter \"view_deadlines\" to check the index.";
public static final String ERROR_DEADLINE_MISSING_INDEX = "Delete command must be followed by the index number!" +
"Enter \"view_deadlines\" to check the index.";
public static final String ERROR_DEADLINE_MISSING_PARAM = "Missing deadline parameter!";
public static final String ERROR_DEADLINE_EXCESS_PARAM = "You cannot have multiple name/time for your deadline!";
public static final String ERROR_DEADLINE_EXCESS_LIST_PARAM =
"Excess input detected! Please only type \"view_deadlines\".";
public static final String ERROR_STAFF_ADD_MISSING_PARAM = "Insufficient information when adding a staff";
public static final String ERROR_MEETING_MISSING_PARAM = "Missing meeting parameter!";
public static final String ERROR_MEETING_EXCESS_ADD_PARAM = "You cannot have multiple name/time for your meeting!";
public static final String ERROR_MEETING_EXCESS_VIEW_PARAM =
"Excess input detected! Please only type \"view_meetings\".";
public static final String ERROR_DISH_INVALID_INDEX = "Your index does not contain a valid dish!";
public static final String ERROR_DISH_NOT_A_VALID_INTEGER = "Your index has to be an integer!";
public static final String ERROR_DISH_BLANK_DISH_NAME_COMMAND = "Name of dish cannot be empty!";
public static final String ERROR_DISH_NEGATIVE_PRICE_COMMAND = "Price of dish cannot be negative!";
public static final String ERROR_DISH_MISSING_INGREDIENT = "Ingredient list cannot be empty!";
public static final String ERROR_DISH_EMPTY_INDEX = "Index cannot be empty!";
}
4 changes: 3 additions & 1 deletion src/main/java/entity/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ public class Deadline {

/**
* Creates a deadline item with the deadline description and deadline timing passed through.
*
* @param description the description of deadline item.
* @param dueDate the deadline of the deadline item.
* @param dueDate the deadline of the deadline item.
*/
public Deadline(String description, String dueDate) {
this.description = description;
Expand All @@ -16,6 +17,7 @@ public Deadline(String description, String dueDate) {

/**
* Returns a String of the deadline and due date for the deadline item in a special format.
*
* @return the string
*/
public String toString() {
Expand Down
Loading

0 comments on commit 602a49c

Please sign in to comment.