Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions JavaFinalProject.iml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,41 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/test/resources" type="java-test-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="TEST">
<library name="JUnit5.8.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.8.1/junit-jupiter-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.8.1/junit-jupiter-api-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.8.1/junit-platform-commons-1.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.8.1/junit-jupiter-params-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.8.1/junit-jupiter-engine-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.8.1/junit-platform-engine-1.8.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="testng">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/testng/testng/7.1.0/testng-7.1.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/beust/jcommander/1.72/jcommander-1.72.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/google/inject/guice/4.1.0/guice-4.1.0-no_aop.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/javax/inject/javax.inject/1/javax.inject-1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/aopalliance/aopalliance/1.0/aopalliance-1.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/19.0/guava-19.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.21/snakeyaml-1.21.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
13 changes: 10 additions & 3 deletions src/com/generation/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 );
}
}
5 changes: 5 additions & 0 deletions src/com/generation/model/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions src/com/generation/service/StudentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
12 changes: 12 additions & 0 deletions src/com/generation/utils/PrinterHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
32 changes: 32 additions & 0 deletions test/com/generation/CourseServiceTest.java
Original file line number Diff line number Diff line change
@@ -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"));
}

}
10 changes: 10 additions & 0 deletions test/com/generation/StudentServiceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.generation;


import com.generation.service.StudentService;

public class StudentServiceTest {
StudentService student1 = new StudentService();
StudentService student2 = new StudentService();

}