diff --git a/JavaFinalProject.iml b/JavaFinalProject.iml
index c90834f..c2e1386 100644
--- a/JavaFinalProject.iml
+++ b/JavaFinalProject.iml
@@ -4,8 +4,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/generation/Main.java b/src/com/generation/Main.java
index 9e24556..d854c64 100644
--- a/src/com/generation/Main.java
+++ b/src/com/generation/Main.java
@@ -6,7 +6,9 @@
import com.generation.service.StudentService;
import com.generation.utils.PrinterHelper;
+import java.text.DateFormat;
import java.text.ParseException;
+import java.util.Date;
import java.util.Scanner;
public class Main
@@ -17,6 +19,7 @@ public static void main( String[] args )
{
StudentService studentService = new StudentService();
CourseService courseService = new CourseService();
+ Student s = new Student("100142436","Maliha Khan","khanmaliha76@gmail.com",new Date(1996,07,02));
Scanner scanner = new Scanner( System.in );
int option = 0;
do
@@ -99,9 +102,13 @@ private static void findStudent( StudentService studentService, Scanner scanner
}
private static void registerStudent( StudentService studentService, Scanner scanner )
- throws ParseException
- {
- Student student = PrinterHelper.createStudentMenu( scanner );
+ throws ParseException{
+
+
+
+
+ Student student = PrinterHelper.createStudentMenu( scanner );
+
studentService.subscribeStudent( student );
}
}
diff --git a/src/com/generation/model/Student.java b/src/com/generation/model/Student.java
index 0897ebe..a314230 100644
--- a/src/com/generation/model/Student.java
+++ b/src/com/generation/model/Student.java
@@ -24,6 +24,8 @@ public Student( String id, String name, String email, Date birthDate )
public void enrollToCourse( Course course )
{
//TODO implement this method
+ courses.add(course);
+
}
public void registerApprovedCourse( Course course )
@@ -35,6 +37,9 @@ public void registerApprovedCourse( Course course )
public boolean isAttendingCourse( String courseCode )
{
//TODO implement this method
+ if(courses.contains(courseCode)){
+ return true;
+ }
return false;
}
diff --git a/src/com/generation/service/StudentService.java b/src/com/generation/service/StudentService.java
index f980e40..6085a8d 100644
--- a/src/com/generation/service/StudentService.java
+++ b/src/com/generation/service/StudentService.java
@@ -27,6 +27,9 @@ public Student findStudent( String studentId )
public void showSummary()
{
//TODO implement
+
+ System.out.println(students.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..c5104d2 100644
--- a/src/com/generation/utils/PrinterHelper.java
+++ b/src/com/generation/utils/PrinterHelper.java
@@ -40,6 +40,18 @@ public static Student createStudentMenu( Scanner scanner )
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
+
+ try {
+
+ formatter.parse(scanner.next());
+
+
+ } catch (ParseException e) {
+
+ System.out.println("Invalid date format. Please type date in this format: MM/DD/YYYY");
+
+ }
+
Date birthDate = formatter.parse( scanner.next());
System.out.println( "|-------------------------------------|" );
Student student = new Student( id, name, email, birthDate );
diff --git a/test/com/generation/CourseServiceTest.java b/test/com/generation/CourseServiceTest.java
new file mode 100644
index 0000000..927e63d
--- /dev/null
+++ b/test/com/generation/CourseServiceTest.java
@@ -0,0 +1,32 @@
+package com.generation;
+
+import com.generation.model.Module;
+
+import com.generation.model.Course;
+
+import com.generation.service.CourseService;
+import org.testng.annotations.Test;
+//import org.testng.annotations.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class CourseServiceTest {
+ Module module = new Module( "INTRO-CS", "Introduction to Computer Science",
+ "Introductory module for the generation technical programs" );
+ Course c = new Course("INTRO-CS-1", "Introduction to Computer Science",9, module);
+ CourseService cs = new CourseService();
+
+ @org.testng.annotations.Test
+ public void getCourse(String courseCode){
+ Course code = cs.getCourse(courseCode);
+ assertTrue(code.equals("INTRO-CS-1"));
+
+ }
+
+ @org.junit.jupiter.api.Test
+ public void registerCourse(Course course){
+ registerCourse(c);
+ assertTrue(c.getCode().equals("INTRO-CS-1"));
+ }
+
+}
diff --git a/test/com/generation/StudentServiceTest.java b/test/com/generation/StudentServiceTest.java
new file mode 100644
index 0000000..547a486
--- /dev/null
+++ b/test/com/generation/StudentServiceTest.java
@@ -0,0 +1,10 @@
+package com.generation;
+
+
+import com.generation.service.StudentService;
+
+public class StudentServiceTest {
+ StudentService student1 = new StudentService();
+ StudentService student2 = new StudentService();
+
+}