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
10 changes: 9 additions & 1 deletion 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
// add course to courses list
courses.add(course);
}

public void registerApprovedCourse( Course course )
Expand All @@ -35,6 +37,12 @@ public void registerApprovedCourse( Course course )
public boolean isAttendingCourse( String courseCode )
{
//TODO implement this method
// check to see if the course code corresponds to any entry in the courses list
for(int i = 0; i < courses.size(); i++) {
if(courseCode.equals(courses.get(i))) {
return true;
}
}
return false;
}

Expand All @@ -47,6 +55,6 @@ public double getAverage()
@Override
public String toString()
{
return "Student {" + super.toString() + "}";
return "Student {" + super.toString() + " " + courses.toString() + "}";
}
}
1 change: 1 addition & 0 deletions src/com/generation/service/CourseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class CourseService

private final Map<String, List<Student>> enrolledStudents = new HashMap<>();


public CourseService()
{
Module module = new Module( "INTRO-CS", "Introduction to Computer Science",
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 @@ -4,6 +4,7 @@
import com.generation.model.Student;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class StudentService
Expand All @@ -27,6 +28,13 @@ public Student findStudent( String studentId )
public void showSummary()
{
//TODO implement
// implement showSummary by using showSummary method in CourseService class as a basis to what the output should look like

System.out.println("Registered Students:");
for (Student student : students.values() ) {
System.out.println(student.toString());
}

}

public void enrollToCourse( String studentId, Course course )
Expand Down
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");
//TODO validate date format and catch exception to avoid crash
Date birthDate = formatter.parse( scanner.next());
boolean validFormat = false;
Date birthDate = null;
while(!validFormat) {
System.out.println( "| Enter student birth date(mm/dd/yyyy)|" );
try {
birthDate = formatter.parse(scanner.next());
validFormat = true;

} catch (ParseException e) {
System.out.println("Please input a valid date.");
}

}

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