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
1 change: 1 addition & 0 deletions .idea/vcs.xml

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

1 change: 1 addition & 0 deletions JavaFinalProject
Submodule JavaFinalProject added at a70b9b
12 changes: 12 additions & 0 deletions src/com/generation/model/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ public Student( String id, String name, String email, Date birthDate )
public void enrollToCourse( Course course )
{
//TODO implement this method

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

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

Expand Down
6 changes: 6 additions & 0 deletions src/com/generation/service/StudentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.generation.model.Course;
import com.generation.model.Student;

import java.security.Key;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -27,6 +28,11 @@ public Student findStudent( String studentId )
public void showSummary()
{
//TODO implement
System.out.println("Students: ");
for (String key: students.keySet()){
Student student = students.get(key);
System.out.println(student);
}
}

public void enrollToCourse( String studentId, Course course )
Expand Down
20 changes: 16 additions & 4 deletions src/com/generation/utils/PrinterHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,23 @@ public static Student createStudentMenu( Scanner scanner )
String email = scanner.next();
System.out.println( "| Enter student birth date(mm/dd/yyyy)|" );
DateFormat formatter = new SimpleDateFormat( "mm/dd/yyyy");
Date birthDate = null;
boolean validDate = false;

//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! " );

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("Invalid date!");
}
} ;
System.out.println("------------------!");
Student student = new Student(id, name, email, birthDate);
System.out.println("Student Successfully Registered!");
System.out.println(student);
return student;
}
Expand Down