forked from nus-cs2113-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from yeekian/branch-AddStudents
Add AddStudentCommand and DeleteStudentCommand
- Loading branch information
Showing
28 changed files
with
665 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import java.util.Scanner; | ||
|
||
/** | ||
* Represents the main class containing the entry point for the TutorLink application | ||
*/ | ||
public class TutorLink { | ||
/** | ||
* Main entry-point for the java.duke.Duke application. | ||
*/ | ||
public static void main(String[] args) { | ||
String logo = "___________ __ .____ .__ __ \n" | ||
+ "\\__ ___/_ ___/ |_ ___________| | |__| ____ | | __\n" | ||
+ " | | | | \\ __\\/ _ \\_ __ \\ | | |/ \\| |/ /\n" | ||
+ " | | | | /| | ( <_> ) | \\/ |___| | | \\ < \n" | ||
+ " |____| |____/ |__| \\____/|__| |_______ \\__|___| /__|_ \\\n" | ||
+ " \\/ \\/ \\/\n"; | ||
System.out.println("Hello from\n" + logo); | ||
System.out.println("What is your name?"); | ||
|
||
Scanner in = new Scanner(System.in); | ||
System.out.println("Hello " + in.nextLine()); | ||
} | ||
} |
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,5 @@ | ||
package exception; | ||
|
||
public class StudentNotFoundException extends Exception{ | ||
//no other code needed | ||
} |
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,33 @@ | ||
package tutorlink.assignmentpackage; | ||
|
||
import java.util.Objects; | ||
|
||
public class Assignment { | ||
private String assginmentDescription; | ||
private double receivedScore; | ||
private double totalScore; | ||
private double weighting; | ||
|
||
public Assignment(String assginmentDescription, double receivedScore, double totalScore, double weighting) { | ||
this.assginmentDescription = assginmentDescription; | ||
this.receivedScore = receivedScore; | ||
this.totalScore = totalScore; | ||
this.weighting = weighting; | ||
} | ||
|
||
public double getWeightedScore() { | ||
return (receivedScore / totalScore) * weighting; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null || getClass() != obj.getClass()){ | ||
return false; | ||
} | ||
Assignment that = (Assignment) obj; | ||
return Objects.equals(assginmentDescription, that.assginmentDescription); | ||
} | ||
} |
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,23 @@ | ||
package tutorlink.attendancepackage; | ||
|
||
public class Attendance { | ||
private String attendanceVenue; | ||
private String attendanceDateTime; //modify this to accept LocalDateTime | ||
private boolean isPresent; | ||
|
||
public Attendance(String attendanceVenue, String localDateTime, boolean isPresent){ | ||
this.attendanceVenue = attendanceVenue; | ||
this.attendanceDateTime = localDateTime; | ||
this.isPresent = isPresent; | ||
} | ||
|
||
public String getAttendanceDateTime() { | ||
return attendanceDateTime; | ||
} | ||
public String getAttendanceVenue() { | ||
return attendanceVenue; | ||
} | ||
public boolean getIsPresent() { | ||
return isPresent; | ||
} | ||
} |
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,21 @@ | ||
package tutorlink.commandpackage; | ||
|
||
import tutorlink.listpackage.ItemList; | ||
|
||
/** | ||
* Represents an interpreted Command from the user. A <code>Command</code> object corresponds to a | ||
* single user-issued command from the terminal. | ||
*/ | ||
public abstract class Command { | ||
/** | ||
* Executes the required operations to perform the command issued by the user. | ||
*/ | ||
public abstract void execute(ItemList list); | ||
|
||
/** | ||
* Checks if the command is an exit command. | ||
* | ||
* @return whether the current command is an ExitCommand | ||
*/ | ||
public abstract boolean isExit(); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/tutorlink/commandpackage/assignmentcommand/AddAssignmentCommand.java
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,24 @@ | ||
package tutorlink.commandpackage.assignmentcommand; | ||
|
||
import tutorlink.assignmentpackage.Assignment; | ||
import tutorlink.listpackage.AssignmentList; | ||
import tutorlink.listpackage.ItemList; | ||
|
||
public class AddAssignmentCommand extends AssignmentCommand { | ||
public AddAssignmentCommand(Assignment assignment) { | ||
super(assignment); | ||
} | ||
|
||
public void execute(ItemList list) { | ||
if (list instanceof AssignmentList) { | ||
((AssignmentList) list).addAssignment(assignment); | ||
} else { | ||
throw new IllegalArgumentException("Invalid list type. Expected StudentList."); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isExit() { | ||
return false; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/tutorlink/commandpackage/assignmentcommand/AssignmentCommand.java
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,16 @@ | ||
package tutorlink.commandpackage.assignmentcommand; | ||
|
||
import tutorlink.commandpackage.Command; | ||
import tutorlink.assignmentpackage.Assignment; | ||
|
||
public abstract class AssignmentCommand extends Command { | ||
protected Assignment assignment; | ||
|
||
public AssignmentCommand(Assignment assignment) { | ||
this.assignment = assignment; | ||
} | ||
|
||
public boolean isExit() { | ||
return false; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/tutorlink/commandpackage/assignmentcommand/DeleteAssignmentCommand.java
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,16 @@ | ||
package tutorlink.commandpackage.assignmentcommand; | ||
|
||
import tutorlink.listpackage.ItemList; | ||
import tutorlink.assignmentpackage.Assignment; | ||
|
||
public class DeleteAssignmentCommand extends AssignmentCommand{ | ||
public DeleteAssignmentCommand(Assignment assignment) { | ||
super(assignment); | ||
} | ||
|
||
|
||
@Override | ||
public void execute(ItemList list) { | ||
|
||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/tutorlink/commandpackage/attendancecommand/AddAttendanceCommand.java
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,16 @@ | ||
package tutorlink.commandpackage.attendancecommand; | ||
|
||
import tutorlink.listpackage.ItemList; | ||
import tutorlink.attendancepackage.Attendance; | ||
|
||
public class AddAttendanceCommand extends AttendanceCommand{ | ||
|
||
public AddAttendanceCommand(Attendance attendance) { | ||
super(attendance); | ||
} | ||
|
||
@Override | ||
public void execute(ItemList list) { | ||
|
||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/tutorlink/commandpackage/attendancecommand/AttendanceCommand.java
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,17 @@ | ||
package tutorlink.commandpackage.attendancecommand; | ||
|
||
import tutorlink.commandpackage.Command; | ||
import tutorlink.attendancepackage.Attendance; | ||
|
||
public abstract class AttendanceCommand extends Command { | ||
private Attendance attendance; | ||
|
||
public AttendanceCommand(Attendance attendance) { | ||
this.attendance = attendance; | ||
} | ||
|
||
@Override | ||
public boolean isExit() { | ||
return false; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/tutorlink/commandpackage/attendancecommand/DeleteAttendanceCommand.java
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,16 @@ | ||
package tutorlink.commandpackage.attendancecommand; | ||
|
||
import tutorlink.listpackage.ItemList; | ||
import tutorlink.attendancepackage.Attendance; | ||
|
||
public class DeleteAttendanceCommand extends AttendanceCommand{ | ||
|
||
public DeleteAttendanceCommand(Attendance attendance) { | ||
super(attendance); | ||
} | ||
|
||
@Override | ||
public void execute(ItemList list) { | ||
|
||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/tutorlink/commandpackage/studentcommand/AddStudentCommand.java
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,27 @@ | ||
package tutorlink.commandpackage.studentcommand; | ||
|
||
import tutorlink.listpackage.ItemList; | ||
import tutorlink.listpackage.StudentList; | ||
import tutorlink.studentpackage.StudentClass; | ||
|
||
public class AddStudentCommand extends StudentCommand { | ||
|
||
public AddStudentCommand(StudentClass student) { | ||
super(student); | ||
} | ||
|
||
// Implement the generic execute method to handle the List type | ||
@Override | ||
public void execute(ItemList list) { | ||
if (list instanceof StudentList) { | ||
((StudentList) list).addStudent(student); | ||
} else { | ||
throw new IllegalArgumentException("Invalid list type. Expected StudentList."); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isExit() { | ||
return super.isExit(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/tutorlink/commandpackage/studentcommand/DeleteStudentCommand.java
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,23 @@ | ||
package tutorlink.commandpackage.studentcommand; | ||
|
||
import tutorlink.listpackage.ItemList; | ||
import tutorlink.listpackage.StudentList; | ||
import tutorlink.studentpackage.StudentClass; | ||
|
||
|
||
public class DeleteStudentCommand extends StudentCommand { | ||
|
||
public DeleteStudentCommand(StudentClass student) { | ||
super(student); | ||
} | ||
|
||
// Implement the generic execute method to handle the List type | ||
@Override | ||
public void execute(ItemList list) { | ||
if (list instanceof StudentList) { | ||
((StudentList) list).deleteStudent(student); | ||
} else { | ||
throw new IllegalArgumentException("Invalid list type. Expected StudentList."); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/tutorlink/commandpackage/studentcommand/StudentCommand.java
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,17 @@ | ||
package tutorlink.commandpackage.studentcommand; | ||
|
||
import tutorlink.commandpackage.Command; | ||
import tutorlink.studentpackage.StudentClass; | ||
|
||
public abstract class StudentCommand extends Command { | ||
protected StudentClass student; | ||
|
||
public StudentCommand(StudentClass student) { | ||
this.student = student; | ||
} | ||
|
||
@Override | ||
public boolean isExit() { | ||
return false; | ||
} | ||
} |
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,29 @@ | ||
package tutorlink.coursepackage; | ||
|
||
import tutorlink.listpackage.AssignmentList; | ||
import tutorlink.listpackage.AttendanceList; | ||
import tutorlink.assignmentpackage.Assignment; | ||
|
||
public class Course { | ||
private String courseID; | ||
private int courseMCs; | ||
private LetterGrade grade; | ||
private AssignmentList assignments; | ||
private AttendanceList attendances; | ||
|
||
|
||
public Course(String courseID, int courseMCs) { | ||
this.courseID = courseID; | ||
this.courseMCs = courseMCs; | ||
assignments = new AssignmentList(); | ||
attendances = new AttendanceList(); | ||
} | ||
|
||
public void addAssignment(Assignment assignment) { | ||
assignments.addAssignment(assignment); | ||
} | ||
|
||
public void deleteAssignment(Assignment assignment) { | ||
assignments.deleteAssignment(assignment); | ||
} | ||
} |
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,29 @@ | ||
package tutorlink.coursepackage; | ||
|
||
public enum LetterGrade { | ||
A_plus,A,A_minus, | ||
B_plus,B,B_minus, | ||
C_plus,C, | ||
D_plus,D, | ||
F, | ||
IP; //In-Progress, no grade available | ||
|
||
public double getGPA(LetterGrade grade) { | ||
double result = 0.0; | ||
switch (grade) { | ||
case A_plus -> result = 5.0; | ||
case A -> result = 5.0; | ||
case A_minus -> result = 4.5; | ||
case B_plus -> result = 4.0; | ||
case B -> result = 3.5; | ||
case B_minus -> result = 3.0; | ||
case C_plus -> result = 2.5; | ||
case C -> result = 2.0; | ||
case D_plus -> result = 1.5; | ||
case D -> result = 1.0; | ||
case F -> result = 0.0; | ||
default -> result = -1.0; //IP case will be -1.0 | ||
} | ||
return result; | ||
} | ||
} |
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,27 @@ | ||
package tutorlink.listpackage; | ||
|
||
import tutorlink.assignmentpackage.Assignment; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class AssignmentList extends ItemList { | ||
private int numberOfAssignments; | ||
private ArrayList<Assignment> assignmentArrayList; | ||
|
||
public AssignmentList() { | ||
this.numberOfAssignments = 0; | ||
this.assignmentArrayList = new ArrayList<>(); | ||
} | ||
|
||
public void deleteAssignment(Assignment assignment){ | ||
assignmentArrayList.remove(assignment); | ||
} | ||
|
||
public void addAssignment(Assignment assignment){ | ||
assignmentArrayList.add(assignment); | ||
} | ||
|
||
public ArrayList<Assignment> getAssignmentArrayList() { | ||
return assignmentArrayList; | ||
} | ||
} |
Oops, something went wrong.