diff --git a/JavaFinalProject.iml b/JavaFinalProject.iml
index c90834f..d8a1435 100644
--- a/JavaFinalProject.iml
+++ b/JavaFinalProject.iml
@@ -7,5 +7,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/generation/model/Student.java b/src/com/generation/model/Student.java
index 0897ebe..014a88e 100644
--- a/src/com/generation/model/Student.java
+++ b/src/com/generation/model/Student.java
@@ -21,9 +21,15 @@ public Student( String id, String name, String email, Date birthDate )
super( id, name, email, birthDate );
}
- public void enrollToCourse( Course course )
- {
+ public void enrollToCourse( Course course ) {
+
+ // ADD a new course into the course instance
//TODO implement this method
+ if(course.getCode().equals(courses)) {
+ System.out.println("Course already exists");
+ } else {
+ courses.add(course);
+ }
}
public void registerApprovedCourse( Course course )
@@ -31,10 +37,14 @@ public void registerApprovedCourse( Course course )
approvedCourses.put( course.getCode(), course );
}
-
- public boolean isAttendingCourse( String courseCode )
- {
+//return true if student is attending class
+ public boolean isAttendingCourse( String courseCode ) {
//TODO implement this method
+ for (Course cour : courses){
+ if (cour.getCode().equals(courseCode)) {
+ return true;
+ }
+ }
return false;
}
diff --git a/src/com/generation/service/StudentService.java b/src/com/generation/service/StudentService.java
index f980e40..b08dc9a 100644
--- a/src/com/generation/service/StudentService.java
+++ b/src/com/generation/service/StudentService.java
@@ -3,6 +3,7 @@
import com.generation.model.Course;
import com.generation.model.Student;
+import java.security.Key;
import java.util.HashMap;
import java.util.Map;
@@ -26,6 +27,10 @@ public Student findStudent( String studentId )
public void showSummary()
{
+ System.out.println("student: ");
+ for(Student stu: students.values()) {
+ System.out.println(stu.toString());
+ }
//TODO implement
}
diff --git a/src/com/generation/service/StudentServiceTest.java b/src/com/generation/service/StudentServiceTest.java
new file mode 100644
index 0000000..b77bf0b
--- /dev/null
+++ b/src/com/generation/service/StudentServiceTest.java
@@ -0,0 +1,18 @@
+package com.generation.service;
+
+import com.generation.model.Student;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class StudentServiceTest {
+ //Student st = new Student("1234","Divine","divine@gmail.com", 01/12/1888);
+ StudentService studentservice = new StudentService();
+
+ @org.junit.jupiter.api.Test
+ void findStudent() {
+ studentservice.findStudent("1234");
+ assertEquals(1234, 1234);
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/generation/utils/PrinterHelper.java b/src/com/generation/utils/PrinterHelper.java
index 6f1ca9b..723ae17 100644
--- a/src/com/generation/utils/PrinterHelper.java
+++ b/src/com/generation/utils/PrinterHelper.java
@@ -38,9 +38,20 @@ 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");
+ DateFormat formatter = new SimpleDateFormat( "MM/dd/yyyy");
//TODO validate date format and catch exception to avoid crash
- Date birthDate = formatter.parse( scanner.next());
+ boolean validDate = false;
+ Date birthDate = null;
+ while(!validDate){
+ System.out.println("Please enter student date of birth(mm/dd/yyyy)");
+ try{
+ birthDate = formatter.parse(scanner.next());
+ validDate = true;
+ } catch(ParseException err){
+ System.out.println(" Wrong format!");
+ }
+ };
+ // Date birthDate = formatter.parse( scanner.next());
System.out.println( "|-------------------------------------|" );
Student student = new Student( id, name, email, birthDate );
System.out.println( "Student Successfully Registered! " );