浏览代码

去除中文

maa3520 1 年之前
父节点
当前提交
1a68dba94f
共有 2 个文件被更改,包括 6 次插入42 次删除
  1. 4 19
      src/ReminderApp.ts
  2. 2 23
      src/RemindersHandler.ts

+ 4 - 19
src/ReminderApp.ts

@@ -66,25 +66,20 @@ export default class ReminderApp {
             ( 3 ) Take result from ( 2 ) and toggle that reminder's completion (this._remindersHandler.toggleCompletion)
             ( 4 ) Logger.log('\n  🏁   Reminder Completion Toggled');
         */
-    // 檢查是否有提醒
+    // Check if there are any reminders
     if (this._remindersHandler.size() === 0) {
       Logger.log("\n  ⚠️  You have no reminders");
       return;
     }
 
-    // (1) 顯示所有提醒
     Logger.logReminders(this._remindersHandler.reminders);
 
-    // (2) 詢問用戶選擇要切換完成狀態的提醒編號
     const reminderIndex = this.getUserChoice("Choose a reminder number to toggle", true);
 
-    // 將用戶選擇從字符串轉換為基於零的索引
     const index = parseInt(reminderIndex) - 1;
 
-    // (3) 切換所選提醒的完成狀態
     this._remindersHandler.toggleCompletion(index);
 
-    // (4) 記錄提醒完成狀態已切換
     Logger.log("\n  🏁   Reminder Completion Toggled");
   }
 
@@ -103,30 +98,24 @@ export default class ReminderApp {
             ( 5 ) If user wishes to also toggle reminder status, do so (this._remindersHandler.toggleCompletion)...feeding in ( 2 )
             ( 6 ) Logger.log('\n  🏁   Reminder Modified');
         */
-    // 檢查是否有提醒
+    // Check if there are any reminders
     if (this._remindersHandler.size() === 0) {
       Logger.log("\n  ⚠️  You have no reminders");
       return;
     }
 
-    // (1) 顯示所有提醒
     Logger.logReminders(this._remindersHandler.reminders);
 
-    // (2) 讓用戶選擇要編輯的提醒編號
     const reminderIndex = this.getUserChoice("reminder number to edit", true);
 
-    // (3) 獲取用戶為提醒輸入的新描述
     const newDescription = this.getUserChoice("new reminder description", false);
 
-    // (4) 修改提醒
     this._remindersHandler.modifyReminder(parseInt(reminderIndex) - 1, newDescription);
 
-    // (5) 如果用戶希望切換提醒狀態
     if (ReminderApp.checkUserToggleChoice()) {
       this._remindersHandler.toggleCompletion(parseInt(reminderIndex) - 1);
     }
 
-    // (6) 記錄提醒已被修改
     Logger.log("\n  🏁   Reminder Modified");
   }
 
@@ -171,16 +160,14 @@ export default class ReminderApp {
               - If not, then call this.searchDescriptions(keyword) and look through each
                 individual reminder. 
     */
-    // 檢查是否有提醒
+    // Check if there are any reminders
     if (this._remindersHandler.size() === 0) {
       Logger.log("\n  ⚠️  You have no reminders");
       return;
     }
 
-    // (1) 詢問用戶輸入搜索關鍵字
     const keyword = this.getUserChoice("Enter a search keyword", false);
 
-    // (2) 執行搜索並記錄結果
     const searchResults = this._remindersHandler.search(keyword);
     Logger.logSearchResults(searchResults);
   }
@@ -195,13 +182,11 @@ export default class ReminderApp {
         otherwise
         ( 1 ) Logger.logGroupedReminders(this._remindersHandler.groupByTag());
     */
-    // 檢查是否有提醒
+    // Check if there are any reminders
     if (this._remindersHandler.size() === 0) {
       Logger.log("\n  ⚠️  You have no reminders");
     } else {
-      // 獲取按標籤分組的提醒
       const groupedReminders = this._remindersHandler.groupByTag();
-      // 記錄分組的提醒
       Logger.logGroupedReminders(groupedReminders);
     }
   }

+ 2 - 23
src/RemindersHandler.ts

@@ -25,7 +25,6 @@ export default class RemindersHandler {
    * Returns the list of reminders added so far.
    */
   public get reminders(): Reminder[] {
-    // 返回 _reminders 數組的副本
     return [...this._reminders];
   }
 
@@ -37,7 +36,6 @@ export default class RemindersHandler {
   public addReminder(description: string, tag: string): void {
     const newReminder = new Reminder(description, tag);
 
-    // 將新的提醒添加到陣列中
     this._reminders.push(newReminder);
   }
 
@@ -79,19 +77,14 @@ export default class RemindersHandler {
    * @param tag - The keyword used to help categorize reminder
    */
   public modifyReminder(index: number, description: string): void {
-    // 檢查索引是否有效
     if (!this.isIndexValid(index)) {
-      return; // 如果索引無效,直接返回
+      return;
     }
 
-    // 獲取特定索引處的提醒
     const reminder = this._reminders[index];
 
-    // 更新提醒的描述
     reminder.description = description;
 
-    // 注意:不需要顯式地將更新後的提醒存回數組,
-    // 因為 JavaScript 中對象是通過引用傳遞的
   }
 
   /**
@@ -100,19 +93,14 @@ export default class RemindersHandler {
    * @param index - The index of the reminder
    */
   public toggleCompletion(index: number): void {
-    // 檢查索引是否有效
     if (!this.isIndexValid(index)) {
-      return; // 如果索引無效,直接返回
+      return;
     }
 
-    // 獲取特定索引處的提醒
     const reminder = this._reminders[index];
 
-    // 切換提醒的完成狀態
     reminder.toggleCompletion();
 
-    // 同樣地,由於 JavaScript 中對象是通過引用傳遞的,
-    // 更改將會直接反映在 `_reminders` 數組中的對應對象上
   }
 
   /**
@@ -125,10 +113,8 @@ export default class RemindersHandler {
   public search(keyword: string): Reminder[] {
     const keywordLower = keyword.toLowerCase();
 
-    // 首先根據標籤搜索
     let results = this.searchTags(keywordLower);
 
-    // 如果沒有找到匹配的標籤,則根據描述搜索
     if (results.length === 0) {
         results = this.searchDescriptions(keywordLower);
       }
@@ -158,17 +144,13 @@ export default class RemindersHandler {
 
         */
 
-    // 遍歷所有提醒
     for (const reminder of this._reminders) {
-      // 獲取標籤,並將其轉換為小寫以實現不區分大小寫
       const tag = reminder.tag.toLowerCase();
 
-      // 如果該標籤還未在分組中則初始化
       if (!groupings[tag]) {
         groupings[tag] = [];
       }
 
-      // 將提醒添加到相應標籤的分組中
       groupings[tag].push(reminder);
     }
 
@@ -180,8 +162,6 @@ export default class RemindersHandler {
    * @param keyword - Text to search for in description and tag
    */
   private searchTags(keyword: string): Reminder[] {
-
-    // 篩選出標籤匹配的提醒
     return this._reminders.filter((reminder) => reminder.tag.toLowerCase() === keyword);
   }
 
@@ -190,7 +170,6 @@ export default class RemindersHandler {
    * @param keyword - Text to search for in description and tag
    */
   private searchDescriptions(keyword: string): Reminder[] {
-    // 篩選出描述中包含關鍵字的提醒
     return this._reminders.filter((reminder) => reminder.description.toLowerCase().includes(keyword));
   }
 }