Skip to content

Commit

Permalink
Improve code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaniceTang committed Nov 10, 2023
1 parent 72c8445 commit 3c7332d
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/main/java/seedu/cafectrl/CafeCtrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
* Initializes the application and starts the interaction with the user.
*/
public class CafeCtrl {

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private final Ui ui;
private Menu menu;
private Command command;
private Pantry pantry;
private Sales sales;
private CurrentDate currentDate;
private Storage storage;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

/**
* Private constructor for the CafeCtrl class, used for initializing the user interface and menu list.
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/cafectrl/command/AddDishCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ public class AddDishCommand extends Command {
+ "[, ingredient/INGREDIENT2_NAME, qty/INGREDIENT2_QTY...]\n"
+ "Example:"
+ COMMAND_WORD + " name/chicken rice price/3.00 ingredient/rice qty/200g, ingredient/chicken qty/100g";

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
protected Menu menu;
protected Ui ui;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

private final Dish dish;
public AddDishCommand(Dish dish, Menu menu, Ui ui) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/cafectrl/command/AddOrderCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ public class AddOrderCommand extends Command {
+ " name/DISH_NAME qty/QUANTITY\n"
+ "Example: " + COMMAND_WORD
+ "name/chicken rice qty/2";

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
protected Pantry pantry;
protected OrderList orderList;
protected Menu menu;
private final Ui ui;
private final Order order;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private final DecimalFormat dollarValue = new DecimalFormat("0.00");

public AddOrderCommand(Order order, Ui ui, Pantry pantry, OrderList orderList, Menu menu) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ public class BuyIngredientCommand extends Command {
+ "[, ingredient/INGREDIENT2_NAME, qty/INGREDIENT2_QTY...]\n"
+ "Example:"
+ COMMAND_WORD + " ingredient/milk qty/200ml, ingredient/chicken qty/100g";

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private static final int FIRST_INDEX = 0;
protected Ui ui;
protected Pantry pantry;
private ArrayList<Ingredient> ingredients;
private ArrayList<Ingredient> ingredientsToBePrinted = new ArrayList<>();
private String ingredientString = ""; // Used to store the message about the bought ingredients
private int FIRST_INDEX = 0;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

/**
* Constructs a BuyIngredientCommand with the specified ingredients, user interface, and pantry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class DeleteDishCommand extends Command {
+ "Parameters: INDEX\n"
+ "Example: " + COMMAND_WORD + " 1";

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
protected Menu menu;
protected Ui ui;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

public DeleteDishCommand(int listIndex, Menu menu, Ui ui) {
this.index = listIndex;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/cafectrl/command/IncorrectCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Represents an incorrect command. Upon execution, produces some feedback to the user.
*/
public class IncorrectCommand extends Command{
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
public final String feedbackToUser;
protected Ui ui;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

public IncorrectCommand(String feedbackToUser, Ui ui) {
this.feedbackToUser = feedbackToUser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class ListIngredientCommand extends Command {
+ "Parameters: DISH_INDEX\n"
+ "Example: " + COMMAND_WORD + " 1";

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
protected Ui ui;
protected Menu menu;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

public ListIngredientCommand(int listIndex, Menu menu, Ui ui) {
this.index = listIndex;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/cafectrl/command/ListMenuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class ListMenuCommand extends Command {
+ COMMAND_WORD;
private static final DecimalFormat dollarValue = new DecimalFormat("0.00");

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private final Menu menu;
private final Ui ui;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

/**
* Constructor for the ListMenuCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public class ListSaleByDayCommand extends Command {
+ COMMAND_WORD + " day/DAY_TO_DISPLAY\n"
+ "Example: " + COMMAND_WORD + " day/1";

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private final int day;
private final Ui ui;
private final Sales sales;
private final Menu menu;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

public ListSaleByDayCommand(int day, Ui ui, Sales sales, Menu menu) {
this.day = day;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/cafectrl/command/ListTotalSales.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
public class ListTotalSales extends Command {
public static final String COMMAND_WORD = "list_total_sales";
public static final String MESSAGE_USAGE = "To show sales for all days:\n" + COMMAND_WORD;

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private Sales sales;
private Ui ui;
private Menu menu;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

public ListTotalSales(Sales sales, Ui ui, Menu menu) {
this.sales = sales;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/cafectrl/command/NextDayCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
import java.util.logging.Logger;

public class NextDayCommand extends Command {

public static final String COMMAND_WORD = "next_day";
public static final String MESSAGE_USAGE = "To travel to next day:\n"
+ COMMAND_WORD;

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private final Ui ui;
private final Sales sales;
private final CurrentDate currentDate;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

public NextDayCommand(Ui ui, Sales sales, CurrentDate currentDate) {
this.ui = ui;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public class PreviousDayCommand extends Command{
public static final String COMMAND_WORD = "previous_day";
public static final String MESSAGE_USAGE = "To go back to previous day:\n" + COMMAND_WORD;

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
protected Ui ui;
protected CurrentDate currentDate;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

public PreviousDayCommand(Ui ui, CurrentDate currentDate) {
this.ui = ui;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

//@@author ShaniceTang
public class ViewTotalStockCommand extends Command {

public static final String COMMAND_WORD = "view_stock";
public static final String MESSAGE_USAGE = "To view pantry stock:\n" + COMMAND_WORD;

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
protected Ui ui;
protected Pantry pantry;
private ArrayList<Ingredient> pantryStock;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

public ViewTotalStockCommand(Pantry pantry, Ui ui) {
this.pantry = pantry;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/cafectrl/data/Chef.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@


public class Chef {
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private final Order order;
private final Pantry pantry;
private final Ui ui;
private Menu menu;
private final DecimalFormat dollarValue = new DecimalFormat("0.00");
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());


public Chef(Order order, Pantry pantry, Ui ui) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/cafectrl/data/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import java.util.logging.Logger;

public class Menu {
private ArrayList<Dish> menuItems;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private ArrayList<Dish> menuItems;

public Menu() {
this.menuItems = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/cafectrl/data/OrderList.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
public class OrderList {
private static final DecimalFormat dollarValue = new DecimalFormat("0.00");
private static final String HEADER_FORMAT = "%-20s %-10s %-20s\n";
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private ArrayList<Order> orderList;
private float totalOrderListCost;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

/**
* Constructs an empty OrderList with no orders and zero total order cost.
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/cafectrl/data/Pantry.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
import java.util.logging.Logger;

public class Pantry {

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private ArrayList<Ingredient> pantryStock;
private Ui ui;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

//@@author NaychiMin
public Pantry(Ui ui, ArrayList<Ingredient> pantryStock) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/seedu/cafectrl/data/Sales.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
* The Sales class represents sales data over a period of time, maintaining a collection of order lists.
*/
public class Sales {

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private static final int DAY_DISPLAY_OFFSET = 1;
private static ArrayList<OrderList> orderLists;
private int daysAccounted;
private final int DAY_DISPLAY_OFFSET = 1;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

public Sales() {
this.orderLists = new ArrayList<>();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/cafectrl/storage/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
* Manage everything related to file such as writing, reading, opening and creating file
*/
public class FileManager {
private final Ui ui;

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
private final Ui ui;

public FileManager(Ui ui) {
this.ui = ui;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/cafectrl/storage/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
* Handles loading and saving data for menu, orderList, pantryStock
*/
public class Storage {

private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());
protected FileManager fileManager;
protected Ui ui;
private static Logger logger = Logger.getLogger(CafeCtrl.class.getName());

public Storage (Ui ui) {
this.fileManager = new FileManager(ui);
Expand Down

0 comments on commit 3c7332d

Please sign in to comment.