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
17 changes: 17 additions & 0 deletions JavaFinalProject.iml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,25 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<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" 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>
15 changes: 9 additions & 6 deletions src/com/generation/model/Student.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package com.generation.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

public class Student
extends Person
Expand All @@ -24,6 +20,7 @@ public Student( String id, String name, String email, Date birthDate )
public void enrollToCourse( Course course )
{
//TODO implement this method
this.courses.add(course);
}

public void registerApprovedCourse( Course course )
Expand All @@ -35,6 +32,12 @@ public void registerApprovedCourse( Course course )
public boolean isAttendingCourse( String courseCode )
{
//TODO implement this method
for (Course course : this.courses) {
if (course.getCode().equals(courseCode)) {
return true;
}
}

return false;
}

Expand All @@ -47,6 +50,6 @@ public double getAverage()
@Override
public String toString()
{
return "Student {" + super.toString() + "}";
return "Student {" + super.toString() + ", " + courses.toString() + "}";
}
}
4 changes: 4 additions & 0 deletions src/com/generation/service/StudentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public Student findStudent( String studentId )
public void showSummary()
{
//TODO implement
System.out.println("This is the summary of students:");
this.students.forEach((k,v) ->{
System.out.println(v.toString());
});
}

public void enrollToCourse( String studentId, Course course )
Expand Down
34 changes: 31 additions & 3 deletions src/com/generation/utils/PrinterHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.format.ResolverStyle;
import java.util.Date;
import java.util.Scanner;

Expand Down Expand Up @@ -37,10 +41,34 @@ 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");

SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
boolean valid = false;
Date birthDate = null;
while (!valid){
System.out.println( "| Enter student birth date(mm/dd/yyyy)|" );
try {

String date = scanner.next();
birthDate = formatter.parse(date);
valid = true;

} catch (ParseException e) {

System.out.println("Invalid Date! Please try again!");


}


}


//DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
//TODO validate date format and catch exception to avoid crash
Date birthDate = formatter.parse( scanner.next());
//Date birthDate = formatter.parse( scanner.next());


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

import org.junit.jupiter.api.Test;

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

class CourseServiceTest {

@Test
void registerCourse() {
}

@Test
void getCourse() {
}

@Test
void enrollStudent() {
}

@Test
void showEnrolledStudents() {
}

@Test
void showSummary() {
}
}
24 changes: 24 additions & 0 deletions test/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() {
}
}