From 26c133fe3b549dc119e905ad649fed1c16a1c0fa Mon Sep 17 00:00:00 2001 From: KrashKart Date: Sun, 20 Oct 2024 23:06:26 +0800 Subject: [PATCH] Tidy code Let's, * remove unnecessary comments * store printed String in a static variable * remove unnecessary methods and method calls --- src/main/java/seedu/address/MainApp.java | 4 ---- .../seedu/address/logic/commands/AbstractFindCommand.java | 2 +- src/main/java/seedu/address/ui/MainWindow.java | 4 +++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index 91858a54630..1778ceeb53c 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -80,12 +80,8 @@ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { try { campusConnectOptional = storage.readCampusConnect(); if (!campusConnectOptional.isPresent()) { - // logger.info("Creating a new data file " + storage.getCampusConnectFilePath() - // + " populated with a sample CampusConnect."); - logger.info("Creating a new data file at: " + storage.getCampusConnectFilePath()); } - // initialData = campusConnectOptional.orElseGet(SampleDataUtil::getSampleCampusConnect); initialData = campusConnectOptional.orElseGet(EmptyDataUtil::getSampleCampusConnect); } catch (DataLoadingException e) { logger.warning("Data file at " + storage.getCampusConnectFilePath() + " could not be loaded." diff --git a/src/main/java/seedu/address/logic/commands/AbstractFindCommand.java b/src/main/java/seedu/address/logic/commands/AbstractFindCommand.java index a7d7f39c9bc..80b649c4c50 100644 --- a/src/main/java/seedu/address/logic/commands/AbstractFindCommand.java +++ b/src/main/java/seedu/address/logic/commands/AbstractFindCommand.java @@ -47,7 +47,7 @@ public CommandResult execute(Model model) { // if the result find list is empty if (model.getFilteredPersonList().isEmpty()) { - return new CommandResult(String.format(MESSAGE_NO_PERSONS_FOUND)); + return new CommandResult(MESSAGE_NO_PERSONS_FOUND); } return new CommandResult( diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 0d5b4d859ad..7100184b230 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -25,6 +25,8 @@ public class MainWindow extends UiPart { private static final String FXML = "MainWindow.fxml"; + private static final String LIST_EMPTY_MESSAGE = "The contact list is empty! :("; + private final Logger logger = LogsCenter.getLogger(getClass()); private Stage primaryStage; @@ -116,7 +118,7 @@ void fillInnerParts() { resultDisplay = new ResultDisplay(); resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); if (logic.getFilteredPersonList().isEmpty()) { - resultDisplay.setFeedbackToUser("The contact list is empty! :("); + resultDisplay.setFeedbackToUser(LIST_EMPTY_MESSAGE); } StatusBarFooter statusBarFooter = new StatusBarFooter(logic.getCampusConnectFilePath());