Skip to content

Commit

Permalink
Merge pull request AY2324S1-CS2103T-T13-0#226 from xCOLOURx/branch-fi…
Browse files Browse the repository at this point in the history
…x-test

Debug Failed Tests
  • Loading branch information
rocketninja7 authored Nov 10, 2023
2 parents 9b93fe8 + 9964084 commit 26559ae
Show file tree
Hide file tree
Showing 44 changed files with 577 additions and 492 deletions.
40 changes: 20 additions & 20 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ModCraft can serve as a **study planner** for your journey in NUS. With ModCraft

This User Guide provides a guide of how to set up ModCraft and a description of useful commands to use. If you are a beginner, we recommend that you start with the [Quick start](#quick-start) guide. Otherwise, feel free to explore the various features from the [Table of Contents](#table-of-contents) below.

This User Guide consists of various visuals to aid your reading.
This User Guide consists of various visuals to aid your reading.

<div class="alert alert-primary"><md>:bulb: **Tip:**
Tips in boxes like this contain information that may be helpful.
Expand All @@ -41,17 +41,17 @@ Provides you with information that is useful to know.
## Table of Contents

1. [Quick start](#quick-start)
2. [Features](#features)
2.1. [Viewing help](#viewing-help-help)
2.2. [Modules](#modules)
2.2.1. [Adding a module](#adding-a-module-add)
2.2.2. [Editing a module](#editing-a-module-edit)
2.2.3. [Deleting a module](#deleting-a-module-delete)
2.2.4. [Finding information about a module](#finding-information-about-a-module-info)
2.3. [Calculating the total current CAP](#calculating-the-total-current-cap-calculatecap)
2.4. [Calculating the total current Modular Credits (MCs)](#calculating-the-total-current-modular-credits-mcs-calculatemc)
2. [Features](#features)
2.1. [Viewing help](#viewing-help-help)
2.2. [Modules](#modules)
2.2.1. [Adding a module](#adding-a-module-add)
2.2.2. [Editing a module](#editing-a-module-edit)
2.2.3. [Deleting a module](#deleting-a-module-delete)
2.2.4. [Finding information about a module](#finding-information-about-a-module-info)
2.3. [Calculating the total current CAP](#calculating-the-total-current-cap-calculatecap)
2.4. [Calculating the total current Modular Credits (MCs)](#calculating-the-total-current-modular-credits-mcs-calculatemc)
2.5. [Exiting the program](#exiting-the-program-exit)
3. [Advanced Use](#advanced-use)
3. [Advanced Use](#advanced-use)
3.1. [Editing the data file](#editing-the-data-file)
4. [FAQ](#faq)
5. [Known issues](#known-issues)
Expand Down Expand Up @@ -150,10 +150,10 @@ In ModCraft, you can specify the **year, semester and grade** of each module whe

<div class="alert alert-primary"><md>:bulb: **Tip:**

The parameter for Year follows a constraint of `0` to `6`, where Year 0 represents the Advance Placement semester.
There is **only one** Advance Placement semester and whenever `y/0` is entered, regardless of the semester entered, the module will be added or edited to the Advance Placement Semester.
The parameter for Year follows a constraint of `0` to `6`, where Year 0 represents the Advance Placement semester.
There is **only one** Advance Placement semester and whenever `y/0` is entered, regardless of the semester entered, the module will be added or edited to the Advance Placement Semester.

The list for the Advance Placement semester and Special Terms 1 and 2 (ST) will only be displayed when there is a module within them.
The list for the Advance Placement semester and Special Terms 1 and 2 (ST) will only be displayed when there is a module within them.

</md></div>

Expand Down Expand Up @@ -189,7 +189,7 @@ These features are planned enhancements in future releases.

### Adding a module: `add`

You can add a module to your study plan of the list of modules taken in the **specified year and semester**.
You can add a module to your study plan of the list of modules taken in the **specified year and semester**.

Format: `add MODULE y/YEAR s/SEM g/GRADE`

Expand All @@ -206,7 +206,7 @@ Below shows what ModCraft should look like for executing the `add` command.
</div>

<div class="alert alert-primary"><md>:bulb: **Tip:**
TTo **plan ahead** using ModCraft, you can input `IP` for grade to represent grade **in progress**.
TTo **plan ahead** using ModCraft, you can input `IP` for grade to represent grade **in progress**.

For **Satisfactory/Unsatisfactory (S/U)** modules, you can insert `S` or `U` as `GRADE`.
</md></div>
Expand Down Expand Up @@ -271,7 +271,7 @@ Deleting a module also **deletes all the information associated with the module*

### Finding Information about a module: `info`

You can retrieve information about **any** module by its module code, including the modules **not** added to the study plan.
You can retrieve information about **any** module by its module code, including the modules **not** added to the study plan.

The **module code, modular credit and module description** of the module will be displayed.

Expand All @@ -281,7 +281,7 @@ Examples:
* `info CS2109S`
* `info CS1010`

Below shows what ModCraft should look like for executing the `info` command.
Below shows what ModCraft should look like for executing the `info` command.

<div style="display:flex; justify-content:space-around; align-items:center;">
<img src="images/ImagesForUG/info-before.png" alt="Before executing info command" style="height:400px; margin:20px;">
Expand All @@ -293,7 +293,7 @@ Below shows what ModCraft should look like for executing the `info` command.
### Calculating the total current CAP: `calculateCAP`

You can calculate the total current CAP of all modules stored in all years and semesters.
ModCraft will calculate the CAP using the formula:
ModCraft will calculate the CAP using the formula:

$\Large\frac{\text{sum of all modules: (grade point of that module * Modular Credits of that module)}}{\text{total Modular Credits}}$.

Expand Down Expand Up @@ -388,7 +388,7 @@ There is no need to save manually.
| **delete** | `delete MODULE_CODE` <br> e.g., `delete CS2040S` |
| **edit** | `edit MODULE_CODE [y/YEAR] [s/SEMESTER] [g/GRADE]` <br> e.g., `edit MA2001 y/1 s/2`, <br/> `edit MA2001 g/A` |
| **info** | `info MODULE_CODE`<br> e.g., `info CS3230` |
| **calculateCAP** | `calculateCAP` |
| **calculateCAP** | `calculateCAP` |
| **calculateMC** | `calculateMC` |
| **help** | `help` |

Expand Down
2 changes: 1 addition & 1 deletion docs/diagrams/EditExecuteSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ deactivate CommandResult
[<-- EditCommand : result
deactivate EditCommand

@enduml
@enduml
2 changes: 1 addition & 1 deletion docs/diagrams/EditParseSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ deactivate EditCommandParser
[<-[hidden]- EditCommandParser
destroy EditCommandParser

@enduml
@enduml
2 changes: 1 addition & 1 deletion docs/diagrams/LogicClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ note right of XYZCommand: XYZCommand = AddCommand, \nDeleteCommand, etc
Logic ..> CommandResult
LogicManager .down.> CommandResult
Command .up.> CommandResult : produces >
@enduml
@enduml
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ This project is **currently ongoing** with the following features **implemented*

This project is based on the AddressBook-Level3 project created by the [SE-EDU initiative](https://se-education.org).

This project also pulls module data from the [NUSMods API](https://api.nusmods.com/v2/).
This project also pulls module data from the [NUSMods API](https://api.nusmods.com/v2/).
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ public boolean equals(Object other) {

ModelManager otherModelManager = (ModelManager) other;
return modulePlan.equals(otherModelManager.modulePlan)
&& userPrefs.equals(otherModelManager.userPrefs);
&& userPrefs.equals(otherModelManager.userPrefs)
&& moduleData.equals(otherModelManager.moduleData);
}

}
1 change: 0 additions & 1 deletion src/main/java/seedu/address/model/module/Description.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public Description(String description) {
* Returns true if a given string is a valid description.
*/
public static boolean isValidDescription(String test) {
// return test.matches(VALIDATION_REGEX);
return true;
}

Expand Down
21 changes: 18 additions & 3 deletions src/main/java/seedu/address/model/module/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public Module(ModuleCode moduleCode, ModuleName moduleName, Description descript
this.grade = null;
}

/**
* Makes a new Module with the fields Year, Semester and Grade set.
*
* @return A new Module with the input fields.
*/
public Module fillUserInputs(Year yearTaken, Semester semesterTaken, Grade grade) {
requireAllNonNull(yearTaken, semesterTaken, grade);

Expand Down Expand Up @@ -123,13 +128,23 @@ public boolean equals(Object other) {
}

Module otherModule = (Module) other;

return this.moduleCode.equals(otherModule.moduleCode)
&& this.moduleName.equals(otherModule.moduleName)
&& this.description.equals(otherModule.description)
&& this.modularCredit.equals(otherModule.modularCredit)
&& this.yearTaken.equals(otherModule.yearTaken)
&& this.semesterTaken.equals(otherModule.semesterTaken)
&& this.grade.equals(otherModule.grade);
&& isEditableFieldEquals(this.yearTaken, otherModule.yearTaken)
&& isEditableFieldEquals(this.semesterTaken, otherModule.semesterTaken)
&& isEditableFieldEquals(this.grade, otherModule.grade);
}

private boolean isEditableFieldEquals(Object thisObj, Object otherObj) {
if (thisObj == null && otherObj == null) {
return true;
} else if (thisObj == null || otherObj == null) {
return false;
}
return thisObj.equals(otherObj);
}

@Override
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/seedu/address/model/module/ModuleName.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ public class ModuleName {
public static final String MESSAGE_CONSTRAINTS =
"Names should only contain alphanumeric characters and spaces, and it should not start with space.";

/*
* The first character of the name must not be a whitespace,
* otherwise " " (a blank string) becomes a valid input.
*/
public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*";

public final String moduleName;

Expand All @@ -34,7 +29,6 @@ public ModuleName(String name) {
* Returns true if a given string is a valid name.
*/
public static boolean isValidName(String test) {
// return test.matches(VALIDATION_REGEX);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@ public boolean checkModuleBelongToSemester(Module m) {
return false;
}

/**
* Checks if the given semester is the same semesters.
*
*/
public boolean checkIfSameSemester(ModulePlanSemester otherModulePlanSemester) {
boolean yearEquals = this.year.equals(otherModulePlanSemester.year);
boolean semesterEquals = this.semester.equals(otherModulePlanSemester.semester);

//For advance placement
if (yearEquals && this.year.equals(Year.YEAR_0)) {
return true;
}

return yearEquals && semesterEquals;
}

/**
* Whether the semester contains any module.
*
Expand Down Expand Up @@ -174,13 +190,10 @@ public boolean equals(Object other) {
ModulePlanSemester otherModulePlanSemester = (ModulePlanSemester) other;
boolean yearEquals = this.year.equals(otherModulePlanSemester.year);
boolean semesterEquals = this.semester.equals(otherModulePlanSemester.semester);
boolean modulesEquals = this.modules.equals(otherModulePlanSemester.modules);

//For advance placement
if (yearEquals && this.year.equals(Year.YEAR_0)) {
return true;
}

return yearEquals && semesterEquals;
return yearEquals && semesterEquals && modulesEquals;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public class ModulePlanSemesterList implements Iterable<ModulePlanSemester> {

private static final List<ModulePlanSemester> DEFAULT_SEMESTERS = new ArrayList<>() {
protected static final List<ModulePlanSemester> DEFAULT_SEMESTERS = new ArrayList<>() {
{
for (int y = 1; y <= 4; y++) {
for (int s = 1; s <= 2; s++) {
Expand Down Expand Up @@ -105,7 +105,7 @@ public void setSemesters(ModulePlanSemesterList replacement) {
public boolean containsSemester(ModulePlanSemester toCheck) {
requireNonNull(toCheck);

return internalList.stream().anyMatch(toCheck::equals);
return internalList.stream().anyMatch(toCheck::checkIfSameSemester);
}

/**
Expand Down Expand Up @@ -152,7 +152,7 @@ private boolean checkIfSemesterEmpty(ModulePlanSemester toCheck) {
}

for (int i = 0; i < internalList.size(); i++) {
if (toCheck.equals(internalList.get(i))) {
if (toCheck.checkIfSameSemester(internalList.get(i))) {
return internalList.get(i).isEmpty();
}
}
Expand All @@ -167,7 +167,7 @@ private boolean checkIfSemesterEmpty(ModulePlanSemester toCheck) {
*/
private boolean inDefaultSemesters(ModulePlanSemester toCheck) {
for (ModulePlanSemester m : DEFAULT_SEMESTERS) {
if (m.equals(toCheck)) {
if (m.checkIfSameSemester(toCheck)) {
return true;
}
}
Expand Down Expand Up @@ -362,7 +362,7 @@ private void refreshList(int index) {
private boolean semestersAreUnique(List<ModulePlanSemester> semesters) {
for (int i = 0; i < semesters.size() - 1; i++) {
for (int j = i + 1; j < semesters.size(); j++) {
if (semesters.get(i).equals(semesters.get(j))) {
if (semesters.get(i).checkIfSameSemester(semesters.get(j))) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/database/moduleinfo.json

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"_comment": "ModulePlan save file which contains the same Module values as in TypicalModules#getTypicalModulePlan()",
"modules" : [ {
"code" : "CS2030S",
"year" : "1",
"sem" : "2",
"grade" : "A",
"name" : "Programming Methodology II",
"description" : "This course is a follow up to CS1010.",
"modularCredit" : "4"
}, {
"code" : "CS2040S",
"year" : "1",
"sem" : "2",
"grade" : "A-",
"name" : "Data Structures and Algorithms",
"description" : "This course introduces the fundamentals of data structures and algorithms.",
"modularCredit" : "4"
}, {
"code" : "CS2100",
"year" : "2",
"sem" : "1",
"grade" : "A",
"name" : "Computer Organisation",
"description" : "Learn about computer organisation",
"modularCredit" : "4"
} ]
}
Loading

0 comments on commit 26559ae

Please sign in to comment.