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
28 changes: 28 additions & 0 deletions JavaFinalProject.iml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,37 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="TEST">
<library name="JUnit4">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.1/junit-4.13.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library" exported="">
<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>
</component>
</module>
14 changes: 14 additions & 0 deletions src/com/generation/model/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ public Student( String id, String name, String email, Date birthDate )
public void enrollToCourse( Course course )
{
//TODO implement this method

//COME BACK TO THIS

if (!isAttendingCourse(course.getCode())) {
courses.add(course);
} else {
System.out.println("Already enrolled");
}

}

public void registerApprovedCourse( Course course )
Expand All @@ -35,6 +44,11 @@ public void registerApprovedCourse( Course course )
public boolean isAttendingCourse( String courseCode )
{
//TODO implement this method
for (int i = 0; i < courses.size(); i++) {
if (courses.get(i).equals(courseCode)) {
return true;
}
}
return false;
}

Expand Down
8 changes: 8 additions & 0 deletions src/com/generation/service/StudentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public Student findStudent( String studentId )
public void showSummary()
{
//TODO implement

System.out.println("Student info:");

for (String key : students.keySet() ) {
Student student = students.get(key);
System.out.println(student);
}

}

public void enrollToCourse( String studentId, Course course )
Expand Down
17 changes: 15 additions & 2 deletions src/com/generation/utils/PrinterHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,22 @@ 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 checkDate = false;
Date birthDate = null;

while(!checkDate) {
System.out.println("| Enter student birth date(mm/dd/yyyy)|");
try {
birthDate = formatter.parse( scanner.next());
checkDate = true;
} catch (ParseException e) {
System.out.println("Wrong date format");
}
};


System.out.println( "|-------------------------------------|" );
Student student = new Student( id, name, email, birthDate );
System.out.println( "Student Successfully Registered! " );
Expand Down
34 changes: 34 additions & 0 deletions test/com/generation/service/StudentServiceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.generation.service;

import com.generation.model.Student;
import org.junit.jupiter.api.BeforeEach;

import static org.junit.jupiter.api.Assertions.*;

class StudentServiceTest {

public StudentService studentService;

@BeforeEach
void testObj(){
studentService = new StudentService();
}

@org.junit.jupiter.api.Test
void subscribeStudent() {
}

@org.junit.jupiter.api.Test
void findStudent() {
Student stdnt = studentService.findStudent("");
assertEquals(null, stdnt);
}

@org.junit.jupiter.api.Test
void showSummary() {
}

@org.junit.jupiter.api.Test
void enrollToCourse() {
}
}