forked from nus-cs2103-AY2324S1/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
214 additions
and
5 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,2 +1,6 @@ | ||
[D][ ] uabrgiub (by: 12 Dec 1212 00:00) | ||
[A][ ] iguiugbf | ||
[A][X] engaou | ||
[A][X] ngoaunjvlao | ||
[A][X] ibagirbg | ||
[A][X] ijbauiebg | ||
[A][ ] rjgbiebgkabg | ||
[D][ ] bgiabrg (by: uvbk) |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package command; | ||
|
||
import duke.DukeException; | ||
import storage.Storage; | ||
import task.Statistics; | ||
import tasklist.TaskList; | ||
import ui.Ui; | ||
|
||
/** | ||
* The `StatisticsCommand` class represents a command to calculate and display task statistics. | ||
* It calculates statistics such as the number of tasks completed within the last week, | ||
* the total number of tasks completed, and the percentages of tasks completed. | ||
* | ||
* @author raydenlim | ||
* @version 0.0.0 | ||
*/ | ||
public class StatisticsCommand extends Command { | ||
/** | ||
* Executes the statistics command by calculating task statistics and returning the result as a formatted string. | ||
* | ||
* @param taskList The `TaskList` containing the tasks for which statistics will be calculated. | ||
* @param ui The user interface component used to display the statistics. | ||
* @param storage The storage component used to load and save data (not used in this command). | ||
* @return A formatted string containing the calculated task statistics. | ||
* @throws DukeException If there is an error calculating or displaying the statistics. | ||
*/ | ||
@Override | ||
public String execute(TaskList taskList, Ui ui, Storage storage) throws DukeException { | ||
Statistics statistics = taskList.calculateStatistics(); | ||
return ui.showStatistics(statistics); | ||
} | ||
} |
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 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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package task; | ||
|
||
/** | ||
* The `Statistics` class represents task statistics, including the number of tasks completed within the last week, | ||
* the total number of tasks completed, the percentage of tasks completed within the last week, and the percentage of | ||
* total tasks completed. | ||
* | ||
* @author raydenlim | ||
* @version 0.0.0 | ||
*/ | ||
public class Statistics { | ||
private int tasksCompletedThisWeek; | ||
private int totalTasksCompleted; | ||
private double percentageCompletedThisWeek; | ||
private double percentageTotalCompleted; | ||
|
||
/** | ||
* Constructs a new `Statistics` object with default values. | ||
* Initially, all statistics values are set to zero. | ||
*/ | ||
public Statistics() { | ||
tasksCompletedThisWeek = 0; | ||
totalTasksCompleted = 0; | ||
percentageCompletedThisWeek = 0.0; | ||
percentageTotalCompleted = 0.0; | ||
} | ||
|
||
/** | ||
* Gets the number of tasks completed within the last week. | ||
* | ||
* @return The number of tasks completed within the last week. | ||
*/ | ||
public int getTasksCompletedThisWeek() { | ||
return tasksCompletedThisWeek; | ||
} | ||
|
||
/** | ||
* Sets the number of tasks completed within the last week. | ||
* | ||
* @param tasksCompletedThisWeek The number of tasks completed within the last week. | ||
*/ | ||
public void setTasksCompletedThisWeek(int tasksCompletedThisWeek) { | ||
this.tasksCompletedThisWeek = tasksCompletedThisWeek; | ||
} | ||
|
||
/** | ||
* Gets the total number of tasks completed. | ||
* | ||
* @return The total number of tasks completed. | ||
*/ | ||
public int getTotalTasksCompleted() { | ||
return totalTasksCompleted; | ||
} | ||
|
||
/** | ||
* Sets the total number of tasks completed. | ||
* | ||
* @param totalTasksCompleted The total number of tasks completed. | ||
*/ | ||
public void setTotalTasksCompleted(int totalTasksCompleted) { | ||
this.totalTasksCompleted = totalTasksCompleted; | ||
} | ||
|
||
/** | ||
* Gets the percentage of tasks completed within the last week. | ||
* | ||
* @return The percentage of tasks completed within the last week. | ||
*/ | ||
public double getPercentageCompletedThisWeek() { | ||
return percentageCompletedThisWeek; | ||
} | ||
|
||
/** | ||
* Sets the percentage of tasks completed within the last week. | ||
* | ||
* @param percentCompletedThisWeek The percentage of tasks completed within the last week. | ||
*/ | ||
public void setPercentageCompletedThisWeek(double percentCompletedThisWeek) { | ||
this.percentageCompletedThisWeek = percentCompletedThisWeek; | ||
} | ||
|
||
/** | ||
* Gets the percentage of total tasks completed. | ||
* | ||
* @return The percentage of total tasks completed. | ||
*/ | ||
public double getPercentageTotalCompleted() { | ||
return percentageTotalCompleted; | ||
} | ||
|
||
/** | ||
* Sets the percentage of total tasks completed. | ||
* | ||
* @param percentTotalCompleted The percentage of total tasks completed. | ||
*/ | ||
public void setPercentageTotalCompleted(double percentTotalCompleted) { | ||
this.percentageTotalCompleted = percentTotalCompleted; | ||
} | ||
} |
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 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 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