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
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

462 changes: 0 additions & 462 deletions .idea/dbnavigator.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/jpa-buddy.xml

This file was deleted.

5 changes: 1 addition & 4 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions JavaFinalProject.iml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,42 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="true" packagePrefix="test" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" exported="" 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" exported="">
<library>
<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>
13 changes: 12 additions & 1 deletion src/com/generation/model/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public Student( String id, String name, String email, Date birthDate )

public void enrollToCourse( Course course )
{
if(!isAttendingCourse(course.getCode())) {
courses.add(course);
}
else{
System.out.println("You are already enrolled in this course.");
}
//TODO implement this method
}

Expand All @@ -31,9 +37,14 @@ public void registerApprovedCourse( Course course )
approvedCourses.put( course.getCode(), course );
}


// Will return true is the student is attending the course that correlates with the courseCode argument
public boolean isAttendingCourse( String courseCode )
{
for(Course course: courses){
if(course.getCode().equals(courseCode)) {
return true;
}
}
//TODO implement this method
return false;
}
Expand Down
26 changes: 26 additions & 0 deletions src/com/generation/service/CourseServiceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.generation.service;

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

class CourseServiceTest {

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

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

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

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

@org.junit.jupiter.api.Test
void showSummary() {
}
}
30 changes: 18 additions & 12 deletions src/com/generation/service/StudentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,35 @@
import java.util.HashMap;
import java.util.Map;

public class StudentService
{
public class StudentService {
private final Map<String, Student> students = new HashMap<>();

public void subscribeStudent( Student student )
{
students.put( student.getId(), student );

public void subscribeStudent(Student student) {
students.put(student.getId(), student);
}

public Student findStudent( String studentId )
{
if ( students.containsKey( studentId ) )
{
return students.get( studentId );
public Student findStudent(String studentId) {
if (students.containsKey(studentId)) {
return students.get(studentId);
}
return null;
}

public void showSummary()
{
//TODO implement
// implement students values to showSummary
System.out.println("Registered Student: ");
for(String key: students.keySet())
{
Student student = students.get( key );
System.out.println(student.toString());
//TODO implement
}
}




public void enrollToCourse( String studentId, Course course )
{
if ( students.containsKey( studentId ) )
Expand Down
24 changes: 24 additions & 0 deletions src/com/generation/service/StudentServiceTest.java
Original file line number Diff line number Diff line change
@@ -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() {
}
}
18 changes: 15 additions & 3 deletions src/com/generation/utils/PrinterHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,22 @@ 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");

DateFormat formatter = new SimpleDateFormat( "MM/dd/yyyy");
boolean validDate = false;
Date birthDate = null;
//TODO validate date format and catch exception to avoid crash
Date birthDate = formatter.parse( scanner.next());
while(!validDate){
System.out.println( "| Enter student birth date(mm/dd/yyyy)|" );
try{
birthDate = formatter.parse( scanner.next());
validDate = true;
}
catch(ParseException e) {
System.out.println("Date is invalid!");
}
}

System.out.println( "|-------------------------------------|" );
Student student = new Student( id, name, email, birthDate );
System.out.println( "Student Successfully Registered! " );
Expand Down