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
2 changes: 1 addition & 1 deletion src/com/generation/model/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public Date getBirthDate()
@Override
public String toString()
{
return id + '\'' + ", name='" + name + '\'' + ", email='" + email + '\'' + ", birthDate=" + birthDate;
return "'"+ id + '\'' + ", name='" + name + '\'' + ", email='" + email + '\'' + ", birthDate=" + birthDate;
}
}
5 changes: 4 additions & 1 deletion src/com/generation/service/StudentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.generation.model.Course;
import com.generation.model.Student;
import java.util.*;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -26,7 +27,9 @@ public Student findStudent( String studentId )

public void showSummary()
{
//TODO implement
for(Student student : students.values()) {
System.out.println(student);
}
}

public void enrollToCourse( String studentId, Course course )
Expand Down
17 changes: 14 additions & 3 deletions src/com/generation/utils/PrinterHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,21 @@ 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");
boolean isCorrectDateFormat = false;
Date birthDate = null;

while(!isCorrectDateFormat) {
System.out.println( "| Enter student birth date(mm/dd/yyyy)|" );
DateFormat formatter = new SimpleDateFormat( "mm/dd/yyyy");
try{
birthDate = formatter.parse( scanner.next());
isCorrectDateFormat = true;
} catch(Exception ex) {
System.out.println( "| Invalid date format, please try again with the correct format (mm/dd/yyyy)|" );
}
}

//TODO validate date format and catch exception to avoid crash
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