diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..e96534f
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/JavaFinalProject.iml b/JavaFinalProject.iml
index c90834f..61d4097 100644
--- a/JavaFinalProject.iml
+++ b/JavaFinalProject.iml
@@ -4,8 +4,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/generation/model/Student.java b/src/com/generation/model/Student.java
index 0897ebe..86028a2 100644
--- a/src/com/generation/model/Student.java
+++ b/src/com/generation/model/Student.java
@@ -23,7 +23,12 @@ public Student( String id, String name, String email, Date birthDate )
public void enrollToCourse( Course course )
{
- //TODO implement this method
+ if (!isAttendingCourse(course.getCode())) {
+ courses.add(course);
+ }
+ else {
+ System.out.println("Student has already been enrolled in the course.");
+ }
}
public void registerApprovedCourse( Course course )
@@ -34,7 +39,11 @@ public void registerApprovedCourse( Course course )
public boolean isAttendingCourse( String courseCode )
{
- //TODO implement this method
+ for(Course c : courses){
+ if(c.getCode().equals(courseCode)) {
+ return true;
+ }
+ }
return false;
}
@@ -47,6 +56,6 @@ public double getAverage()
@Override
public String toString()
{
- return "Student {" + super.toString() + "}";
+ return "Student {" + super.toString() + ", " + courses.toString() + "}";
}
}
diff --git a/src/com/generation/service/StudentService.java b/src/com/generation/service/StudentService.java
index f980e40..fbf3ab6 100644
--- a/src/com/generation/service/StudentService.java
+++ b/src/com/generation/service/StudentService.java
@@ -26,7 +26,10 @@ public Student findStudent( String studentId )
public void showSummary()
{
- //TODO implement
+ System.out.println("Students: ");
+ for(Student s: students.values()){
+ System.out.println(s.toString());
+ }
}
public void enrollToCourse( String studentId, Course course )
diff --git a/src/com/generation/utils/PrinterHelper.java b/src/com/generation/utils/PrinterHelper.java
index 6f1ca9b..b689b9f 100644
--- a/src/com/generation/utils/PrinterHelper.java
+++ b/src/com/generation/utils/PrinterHelper.java
@@ -38,9 +38,18 @@ public static Student createStudentMenu( Scanner scanner )
System.out.println( "| Enter student email: |" );
String email = scanner.next();
System.out.println( "| Enter student birth date(mm/dd/yyyy)|" );
- DateFormat formatter = new SimpleDateFormat( "mm/dd/yyyy");
- //TODO validate date format and catch exception to avoid crash
- Date birthDate = formatter.parse( scanner.next());
+ DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
+ boolean validDate = false;
+ Date birthDate = null;
+ while(!validDate) {
+ System.out.println("| Enter Student Birth Date (mm/dd/yyyy)|");
+ try {
+ birthDate = formatter.parse( scanner.next());
+ validDate = true;
+ } catch (ParseException e) {
+ System.out.println("Invalid Date!");
+ }
+ };
System.out.println( "|-------------------------------------|" );
Student student = new Student( id, name, email, birthDate );
System.out.println( "Student Successfully Registered! " );
diff --git a/src/test/com/generation/service/CourseServiceTest.java b/src/test/com/generation/service/CourseServiceTest.java
new file mode 100644
index 0000000..d7759a4
--- /dev/null
+++ b/src/test/com/generation/service/CourseServiceTest.java
@@ -0,0 +1,19 @@
+package com.generation.service;
+
+import com.generation.model.Course;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class CourseServiceTest {
+
+ public CourseService courseService = new CourseService();
+
+
+ @Test
+ void getCourseNull() {
+ Course course = courseService.getCourse("Invalid Course Code");
+ assertNull(course);
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/com/generation/service/StudentServiceTest.java b/src/test/com/generation/service/StudentServiceTest.java
new file mode 100644
index 0000000..a18079b
--- /dev/null
+++ b/src/test/com/generation/service/StudentServiceTest.java
@@ -0,0 +1,11 @@
+package com.generation.service;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class StudentServiceTest {
+
+ public StudentService student = new StudentService();
+
+
+
+}
\ No newline at end of file