Skip to content

Commit

Permalink
attempt to create new Task objects with course tasks entered by instr…
Browse files Browse the repository at this point in the history
…uctor user in course creation user case (unable to, Task is abstract), CourseEnrolmentDsGateway commented out + will be removed as don't think it is needed, adding course enrolment screen to Main (does not run, need to debug)
  • Loading branch information
jltng committed Nov 26, 2022
1 parent d5a7f5a commit 55e8b10
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
10 changes: 10 additions & 0 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import course_creation_use_case.*;
//import course_enrolment_use_case.CourseEnrolmentDsGateway;
import course_enrolment_use_case.CourseEnrolmentInputBoundary;
import course_enrolment_use_case.CourseEnrolmentInteractor;
import course_enrolment_use_case.CourseEnrolmentOutputBoundary;
import entities.*;
import event_creation_screens.*;
import event_creation_use_case.*;
Expand Down Expand Up @@ -53,6 +57,10 @@ public static void main(String[] args) {
CourseCreationInputBoundary interactor = new CourseCreationInteractor(course, presenter, courseMap);
CourseCreationController courseCreationController = new CourseCreationController(interactor);

// CourseEnrolmentOutputBoundary enrolmentPresenter = new CourseEnrolmentPresenter();
// CourseEnrolmentInputBoundary enrolmentInteractor = new CourseEnrolmentInteractor (enrolmentPresenter, courseMap, user.getName());
// CourseEnrolmentController enrolmentController = new CourseEnrolmentController(enrolmentInteractor);

// Build the GUI
EventCreationScreen taskScreen = new EventCreationScreen(eventCreationController, screens, cardLayout);
screens.add("toDoList", taskScreen);
Expand All @@ -66,6 +74,8 @@ public static void main(String[] args) {
CourseCreationScreen courseCreationScreen = new CourseCreationScreen(courseCreationController, screens, cardLayout);
screens.add("course", courseCreationScreen);

// CourseEnrolmentScreen courseEnrolmentScreen = new CourseEnrolmentScreen(enrolmentController);

MainScreen mainScreen = new MainScreen(screens, cardLayout);
screens.add("main", mainScreen);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import entities.*;

import java.util.ArrayList;

public class CourseCreationInteractor implements CourseCreationInputBoundary {
final CourseCreationDsGateway courseCreationDSGateway;
final CourseCreationOutputBoundary courseCreationOutputBoundary;
Expand Down Expand Up @@ -31,6 +33,7 @@ public CourseCreationResponseModel create(CourseCreationRequestModel requestMode
// Note: Jonathan - no need to check the type of User, students and instructors
// would have different views because they are in different use cases
// checks whether the course id is already in the CourseMap (course already exists)

if (courseCreationDSGateway.existsByCourseID(requestModel.getCourseID())) {
return courseCreationOutputBoundary.prepareFailView("Course already exists.");
}
Expand All @@ -45,6 +48,13 @@ public CourseCreationResponseModel create(CourseCreationRequestModel requestMode
CourseCreationRequestModel courseCreationModel = new CourseCreationRequestModel(course.getCourseName(), course.getCourseInstructor(), course.getTasks());
courseCreationDSGateway.saveCourse(courseCreationModel);

// tasks from course (task id will be course name + task number / index of task in arraylist)
ArrayList<String> courseTasks = course.getTasks();
for (String task : courseTasks) {
// need to initialize new task to add course tasks to TaskMap, but unable to since Task is abstract
// TaskMap.addTask(course.getCourseName() + courseTasks.indexOf(task), task);
}

// course sent to presenter
CourseCreationResponseModel courseResponseModel = new CourseCreationResponseModel(
course.getCourseID(), course.getTasks());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package course_enrolment_use_case;
// don't think this is needed?

// Use case layer

public interface CourseEnrolmentDsGateway {
// checks if student is in the course through the students argument of the Course
// object (value) from the course id (key)
boolean existsByStudent(String studentIdentifier);

void saveStudent(CourseEnrolmentRequestModel requestModel);
}
//package course_enrolment_use_case;
//
//// Use case layer
//
//public interface CourseEnrolmentDsGateway {
// // checks if student is in the course through the students argument of the Course
// // object (value) from the course id (key)
// boolean existsByStudent(String studentIdentifier);
//
// void saveStudent(CourseEnrolmentRequestModel requestModel);
//}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
import java.util.ArrayList;

public class CourseEnrolmentInteractor implements CourseEnrolmentInputBoundary {
final CourseEnrolmentDsGateway courseEnrolmentDsGateway;
final CourseEnrolmentOutputBoundary courseEnrolmentOutputBoundary;
final CourseMap courseMap;
final String studentID;

public CourseEnrolmentInteractor(CourseEnrolmentDsGateway courseEnrolmentDsGateway, CourseEnrolmentOutputBoundary courseEnrolmentOutputBoundary,
public CourseEnrolmentInteractor(CourseEnrolmentOutputBoundary courseEnrolmentOutputBoundary,
CourseMap courseMap, String studentID) {
this.courseEnrolmentDsGateway = courseEnrolmentDsGateway;
this.courseEnrolmentOutputBoundary = courseEnrolmentOutputBoundary;
this.courseMap = courseMap;
this.studentID = studentID;
Expand Down

0 comments on commit 55e8b10

Please sign in to comment.