diff --git a/JavaFinalProject.iml b/JavaFinalProject.iml
index c90834f..86d3dd7 100644
--- a/JavaFinalProject.iml
+++ b/JavaFinalProject.iml
@@ -4,8 +4,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/generation/model/Student.java b/src/com/generation/model/Student.java
index 0897ebe..d5d89f9 100644
--- a/src/com/generation/model/Student.java
+++ b/src/com/generation/model/Student.java
@@ -1,10 +1,6 @@
package com.generation.model;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
public class Student
extends Person
@@ -24,6 +20,7 @@ public Student( String id, String name, String email, Date birthDate )
public void enrollToCourse( Course course )
{
//TODO implement this method
+ this.courses.add(course);
}
public void registerApprovedCourse( Course course )
@@ -35,6 +32,12 @@ public void registerApprovedCourse( Course course )
public boolean isAttendingCourse( String courseCode )
{
//TODO implement this method
+ for (Course course : this.courses) {
+ if (course.getCode().equals(courseCode)) {
+ return true;
+ }
+ }
+
return false;
}
@@ -47,6 +50,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..b535dc7 100644
--- a/src/com/generation/service/StudentService.java
+++ b/src/com/generation/service/StudentService.java
@@ -27,6 +27,10 @@ public Student findStudent( String studentId )
public void showSummary()
{
//TODO implement
+ System.out.println("This is the summary of students:");
+ this.students.forEach((k,v) ->{
+ System.out.println(v.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..37eb957 100644
--- a/src/com/generation/utils/PrinterHelper.java
+++ b/src/com/generation/utils/PrinterHelper.java
@@ -5,6 +5,10 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.time.format.ResolverStyle;
import java.util.Date;
import java.util.Scanner;
@@ -37,10 +41,34 @@ public static Student createStudentMenu( Scanner scanner )
String id = scanner.next();
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");
+
+ SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
+ boolean valid = false;
+ Date birthDate = null;
+ while (!valid){
+ System.out.println( "| Enter student birth date(mm/dd/yyyy)|" );
+ try {
+
+ String date = scanner.next();
+ birthDate = formatter.parse(date);
+ valid = true;
+
+ } catch (ParseException e) {
+
+ System.out.println("Invalid Date! Please try again!");
+
+
+ }
+
+
+ }
+
+
+ //DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
//TODO validate date format and catch exception to avoid crash
- Date birthDate = formatter.parse( scanner.next());
+ //Date birthDate = formatter.parse( scanner.next());
+
+
System.out.println( "|-------------------------------------|" );
Student student = new Student( id, name, email, birthDate );
System.out.println( "Student Successfully Registered! " );
diff --git a/test/com/generation/service/CourseServiceTest.java b/test/com/generation/service/CourseServiceTest.java
new file mode 100644
index 0000000..d7f98cd
--- /dev/null
+++ b/test/com/generation/service/CourseServiceTest.java
@@ -0,0 +1,28 @@
+package com.generation.service;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class CourseServiceTest {
+
+ @Test
+ void registerCourse() {
+ }
+
+ @Test
+ void getCourse() {
+ }
+
+ @Test
+ void enrollStudent() {
+ }
+
+ @Test
+ void showEnrolledStudents() {
+ }
+
+ @Test
+ void showSummary() {
+ }
+}
\ No newline at end of file
diff --git a/test/com/generation/service/StudentServiceTest.java b/test/com/generation/service/StudentServiceTest.java
new file mode 100644
index 0000000..761f15d
--- /dev/null
+++ b/test/com/generation/service/StudentServiceTest.java
@@ -0,0 +1,24 @@
+package com.generation.service;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class StudentServiceTest {
+
+ @Test
+ void subscribeStudent() {
+ }
+
+ @Test
+ void findStudent() {
+ }
+
+ @Test
+ void showSummary() {
+ }
+
+ @Test
+ void enrollToCourse() {
+ }
+}
\ No newline at end of file