├── .gitignore ├── .idea ├── .gitignore ├── dbnavigator.xml ├── jpa-buddy.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── JAVA-13 - Final Project.iml ├── JavaFinalProject.iml ├── README.md └── src └── com └── generation ├── Main.java ├── model ├── Course.java ├── Evaluation.java ├── Instructor.java ├── Module.java ├── Person.java └── Student.java ├── service ├── CourseService.java └── StudentService.java └── utils └── PrinterHelper.java /.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/dbnavigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | -------------------------------------------------------------------------------- /.idea/jpa-buddy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /JAVA-13 - Final Project.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JavaFinalProject.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # Java Programming Fundamentals - Assessment 5 | 6 |
7 |
8 | It's time to see how much you learned about Java and Object-Oriented Programming. 9 | 10 | ## Part 1: Understanding the StudentGen project 11 | 1. Download the source code and import the project using IntelliJ Idea or any other IDE you prefer. 12 | 2. Understand the project structure: 13 | * Packages 14 | * Classes 15 | * Functionality 16 | 3. Run and test the project to get a deeper understanding of how it works (remember the persistence mindset!). 17 | 4. You will be working on the StudentService class, the Student class, the PrinterHelper class, and the Main class. 18 | 19 | ## Part 2: Implementing the Student and StudentService missing features 20 | 1. Open the *Student* class (`src/com/generation/model/Student.java`) and implement the following methods: 21 | 22 | ```java 23 | public void enrollToCourse( Course course ) 24 | { 25 | //TODO implement this method 26 | } 27 | 28 | public boolean isAttendingCourse( String courseCode ) 29 | { 30 | //TODO implement this method 31 | return false; 32 | } 33 | ``` 34 | 35 | 2. Open the *StudentService* class (`src/com/generation/service/StudentService.java`) and implement the following methods: 36 | 37 | ```java 38 | 39 | public void showSummary() 40 | { 41 | //TODO implement 42 | } 43 | ``` 44 | 45 | Hint: To show the summary use `System.out.println()` to print out to the console. 46 | 47 | ## Part 3: Trying out your new functionality in the main method 48 | 49 | 50 | 1. Test the program to verify it works as expected: 51 | * Create a new student. 52 | * Enroll the student to a few courses. 53 | * Show the students and courses summary and verify that data is correct. 54 | 55 | 56 | ## Part 4: Handling exceptions 57 | 1. Register a new user providing a wrong date format. 58 | 2. Modify the createStudentMenu method of the PrinterHelper class so that it handles correctly the exception when a wrong date format is inserted by the user. 59 | 3. Catch the exception and show a proper message to the user. 60 | 61 | ## Challenge Yourself 62 | 1. Write 2 Unit tests for the class *StudentService* 63 | 2. Write 2 Unit tests for the class *CourseService* 64 | 3. Remember that this will involve setting up your testing environment! (Refer to instructions shared in the student slack channel if you need them) -------------------------------------------------------------------------------- /src/com/generation/Main.java: -------------------------------------------------------------------------------- 1 | package com.generation; 2 | 3 | import com.generation.model.Course; 4 | import com.generation.model.Student; 5 | import com.generation.service.CourseService; 6 | import com.generation.service.StudentService; 7 | import com.generation.utils.PrinterHelper; 8 | 9 | import java.text.ParseException; 10 | import java.util.Scanner; 11 | 12 | public class Main 13 | { 14 | 15 | public static void main( String[] args ) 16 | throws ParseException 17 | { 18 | StudentService studentService = new StudentService(); 19 | CourseService courseService = new CourseService(); 20 | Scanner scanner = new Scanner( System.in ); 21 | int option = 0; 22 | do 23 | { 24 | PrinterHelper.showMainMenu(); 25 | option = scanner.nextInt(); 26 | switch ( option ) 27 | { 28 | case 1: 29 | registerStudent( studentService, scanner ); 30 | break; 31 | case 2: 32 | findStudent( studentService, scanner ); 33 | break; 34 | case 3: 35 | enrollStudentToCourse( studentService, courseService, scanner ); 36 | break; 37 | case 4: 38 | showStudentsSummary( studentService, scanner ); 39 | break; 40 | case 5: 41 | showCoursesSummary( courseService, scanner ); 42 | break; 43 | } 44 | } 45 | while ( option != 6 ); 46 | } 47 | 48 | private static void enrollStudentToCourse( StudentService studentService, CourseService courseService, 49 | Scanner scanner ) 50 | { 51 | System.out.println( "Insert student ID" ); 52 | String studentId = scanner.next(); 53 | Student student = studentService.findStudent( studentId ); 54 | if ( student == null ) 55 | { 56 | System.out.println( "Invalid Student ID" ); 57 | return; 58 | } 59 | System.out.println( student ); 60 | System.out.println( "Insert course ID" ); 61 | String courseId = scanner.next(); 62 | Course course = courseService.getCourse( courseId ); 63 | if ( course == null ) 64 | { 65 | System.out.println( "Invalid Course ID" ); 66 | return; 67 | } 68 | System.out.println( course ); 69 | courseService.enrollStudent( courseId, student ); 70 | studentService.enrollToCourse( studentId, course ); 71 | System.out.println( "Student with ID: " + studentId + " enrolled successfully to " + courseId ); 72 | 73 | } 74 | 75 | private static void showCoursesSummary( CourseService courseService, Scanner scanner ) 76 | { 77 | courseService.showSummary(); 78 | } 79 | 80 | private static void showStudentsSummary( StudentService studentService, Scanner scanner ) 81 | { 82 | studentService.showSummary(); 83 | } 84 | 85 | private static void findStudent( StudentService studentService, Scanner scanner ) 86 | { 87 | System.out.println( "Enter student ID: " ); 88 | String studentId = scanner.next(); 89 | Student student = studentService.findStudent( studentId ); 90 | if ( student != null ) 91 | { 92 | System.out.println( "Student Found: " ); 93 | System.out.println( student ); 94 | } 95 | else 96 | { 97 | System.out.println( "Student with Id = " + studentId + " not found" ); 98 | } 99 | } 100 | 101 | private static void registerStudent( StudentService studentService, Scanner scanner ) 102 | throws ParseException 103 | { 104 | Student student = PrinterHelper.createStudentMenu( scanner ); 105 | studentService.subscribeStudent( student ); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/com/generation/model/Course.java: -------------------------------------------------------------------------------- 1 | package com.generation.model; 2 | 3 | public class Course 4 | { 5 | private final String code; 6 | 7 | private final String name; 8 | 9 | private final int credits; 10 | 11 | private final Module module; 12 | 13 | 14 | public Course( String code, String name, int credits, Module module ) 15 | { 16 | this.code = code; 17 | this.name = name; 18 | this.credits = credits; 19 | this.module = module; 20 | } 21 | 22 | public String getCode() 23 | { 24 | return code; 25 | } 26 | 27 | public String getName() 28 | { 29 | return name; 30 | } 31 | 32 | public int getCredits() 33 | { 34 | return credits; 35 | } 36 | 37 | public Module getModule() 38 | { 39 | return module; 40 | } 41 | 42 | @Override 43 | public String toString() 44 | { 45 | return "Course{" + "code='" + code + '\'' + ", name='" + name + '\'' + ", credits=" + credits + ", module=" 46 | + module + '}'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/com/generation/model/Evaluation.java: -------------------------------------------------------------------------------- 1 | package com.generation.model; 2 | 3 | import java.util.List; 4 | 5 | public interface Evaluation 6 | { 7 | double getAverage(); 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/com/generation/model/Instructor.java: -------------------------------------------------------------------------------- 1 | package com.generation.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | public class Instructor 8 | extends Person 9 | { 10 | 11 | private int experienceMonths; 12 | 13 | private final List teachingCourses = new ArrayList<>(); 14 | 15 | protected Instructor( String id, String name, String email, Date birthDate ) 16 | { 17 | super( id, name, email, birthDate ); 18 | } 19 | 20 | public int getExperienceMonths() 21 | { 22 | return experienceMonths; 23 | } 24 | 25 | public void setExperienceMonths( int experienceMonths ) 26 | { 27 | this.experienceMonths = experienceMonths; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/com/generation/model/Module.java: -------------------------------------------------------------------------------- 1 | package com.generation.model; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class Module 7 | { 8 | private final String code; 9 | 10 | private final String name; 11 | 12 | private final String description; 13 | 14 | private final Map prerequisites = new HashMap<>(); 15 | 16 | public Module( String code, String name, String description ) 17 | { 18 | this.code = code; 19 | this.name = name; 20 | this.description = description; 21 | } 22 | 23 | public void addPrerequisite( Module module ) 24 | { 25 | prerequisites.put( module.code, module ); 26 | } 27 | 28 | 29 | public String getCode() 30 | { 31 | return code; 32 | } 33 | 34 | public String getName() 35 | { 36 | return name; 37 | } 38 | 39 | public String getDescription() 40 | { 41 | return description; 42 | } 43 | 44 | public Map getPrerequisites() 45 | { 46 | return prerequisites; 47 | } 48 | 49 | @Override 50 | public String toString() 51 | { 52 | return "Module{" + "name='" + name + '\'' + '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/com/generation/model/Person.java: -------------------------------------------------------------------------------- 1 | package com.generation.model; 2 | 3 | import java.util.Date; 4 | 5 | abstract public class Person 6 | { 7 | private final String id; 8 | 9 | private final String name; 10 | 11 | private final String email; 12 | 13 | private final Date birthDate; 14 | 15 | protected Person( String id, String name, String email, Date birthDate ) 16 | { 17 | this.id = id; 18 | this.name = name; 19 | this.email = email; 20 | this.birthDate = birthDate; 21 | } 22 | 23 | public String getId() 24 | { 25 | return id; 26 | } 27 | 28 | public String getName() 29 | { 30 | return name; 31 | } 32 | 33 | public String getEmail() 34 | { 35 | return email; 36 | } 37 | 38 | public Date getBirthDate() 39 | { 40 | return birthDate; 41 | } 42 | 43 | @Override 44 | public String toString() 45 | { 46 | return id + '\'' + ", name='" + name + '\'' + ", email='" + email + '\'' + ", birthDate=" + birthDate; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/com/generation/model/Student.java: -------------------------------------------------------------------------------- 1 | package com.generation.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class Student 10 | extends Person 11 | implements Evaluation 12 | { 13 | private double average; 14 | 15 | private final List courses = new ArrayList<>(); 16 | 17 | private final Map approvedCourses = new HashMap<>(); 18 | 19 | public Student( String id, String name, String email, Date birthDate ) 20 | { 21 | super( id, name, email, birthDate ); 22 | } 23 | 24 | public void enrollToCourse( Course course ) 25 | { 26 | //TODO implement this method 27 | } 28 | 29 | public void registerApprovedCourse( Course course ) 30 | { 31 | approvedCourses.put( course.getCode(), course ); 32 | } 33 | 34 | 35 | public boolean isAttendingCourse( String courseCode ) 36 | { 37 | //TODO implement this method 38 | return false; 39 | } 40 | 41 | @Override 42 | public double getAverage() 43 | { 44 | return average; 45 | } 46 | 47 | @Override 48 | public String toString() 49 | { 50 | return "Student {" + super.toString() + "}"; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/com/generation/service/CourseService.java: -------------------------------------------------------------------------------- 1 | package com.generation.service; 2 | 3 | import com.generation.model.Course; 4 | import com.generation.model.Module; 5 | import com.generation.model.Student; 6 | 7 | import java.util.ArrayList; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | public class CourseService 13 | { 14 | private final Map courses = new HashMap<>(); 15 | 16 | private final Map> enrolledStudents = new HashMap<>(); 17 | 18 | public CourseService() 19 | { 20 | Module module = new Module( "INTRO-CS", "Introduction to Computer Science", 21 | "Introductory module for the generation technical programs" ); 22 | registerCourse( new Course( "INTRO-CS-1", "Introduction to Computer Science", 9, module ) ); 23 | registerCourse( new Course( "INTRO-CS-2", "Introduction to Algorithms", 9, module ) ); 24 | registerCourse( new Course( "INTRO-CS-3", "Algorithm Design and Problem Solving - Introduction ", 9, module ) ); 25 | registerCourse( new Course( "INTRO-CS-4", "Algorithm Design and Problem Solving - Advanced", 9, module ) ); 26 | registerCourse( new Course( "INTRO-CS-5", "Terminal Fundamentals", 9, module ) ); 27 | registerCourse( new Course( "INTRO-CS-6", "Source Control Using Git and Github", 9, module ) ); 28 | registerCourse( new Course( "INTRO-CS-7", "Agile Software Development with SCRUM", 9, module ) ); 29 | 30 | Module moduleWebFundamentals = new Module( "INTRO-WEB", "Web Development Fundamentals", 31 | "Introduction to fundamentals of web development" ); 32 | registerCourse( new Course( "INTRO-WEB-1", "Introduction to Web Applications", 9, moduleWebFundamentals ) ); 33 | registerCourse( new Course( "INTRO-WEB-2", "Introduction to HTML", 9, moduleWebFundamentals ) ); 34 | registerCourse( new Course( "INTRO-WEB-3", "Introduction to CSS", 9, moduleWebFundamentals ) ); 35 | registerCourse( new Course( "INTRO-WEB-4", "Advanced HTML", 9, moduleWebFundamentals ) ); 36 | registerCourse( new Course( "INTRO-WEB-5", "Advanced CSS", 9, moduleWebFundamentals ) ); 37 | registerCourse( new Course( "INTRO-WEB-6", "Introduction to Bootstrap Framework", 9, moduleWebFundamentals ) ); 38 | registerCourse( 39 | new Course( "INTRO-WEB-7", "Introduction to JavaScript for Web Development", 9, moduleWebFundamentals ) ); 40 | 41 | } 42 | 43 | public void registerCourse( Course course ) 44 | { 45 | courses.put( course.getCode(), course ); 46 | } 47 | 48 | public Course getCourse( String code ) 49 | { 50 | if ( courses.containsKey( code ) ) 51 | { 52 | return courses.get( code ); 53 | } 54 | return null; 55 | } 56 | 57 | public void enrollStudent( String courseId, Student student ) 58 | { 59 | if ( !enrolledStudents.containsKey( courseId ) ) 60 | { 61 | enrolledStudents.put( courseId, new ArrayList<>() ); 62 | } 63 | enrolledStudents.get( courseId ).add( student ); 64 | } 65 | 66 | public void showEnrolledStudents( String courseId ) 67 | { 68 | if ( enrolledStudents.containsKey( courseId ) ) 69 | { 70 | List students = enrolledStudents.get( courseId ); 71 | for ( Student student : students ) 72 | { 73 | System.out.println( student ); 74 | } 75 | } 76 | } 77 | 78 | 79 | public void showSummary() 80 | { 81 | System.out.println( "Available Courses:" ); 82 | for ( String key : courses.keySet() ) 83 | { 84 | Course course = courses.get( key ); 85 | System.out.println( course ); 86 | } 87 | System.out.println( "Enrolled Students" ); 88 | for ( String key : enrolledStudents.keySet() ) 89 | { 90 | List students = enrolledStudents.get( key ); 91 | System.out.println( "Students on Course " + key + ": " ); 92 | for ( Student student : students ) 93 | { 94 | System.out.println( student ); 95 | } 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/com/generation/service/StudentService.java: -------------------------------------------------------------------------------- 1 | package com.generation.service; 2 | 3 | import com.generation.model.Course; 4 | import com.generation.model.Student; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | public class StudentService 10 | { 11 | private final Map students = new HashMap<>(); 12 | 13 | public void subscribeStudent( Student student ) 14 | { 15 | students.put( student.getId(), student ); 16 | } 17 | 18 | public Student findStudent( String studentId ) 19 | { 20 | if ( students.containsKey( studentId ) ) 21 | { 22 | return students.get( studentId ); 23 | } 24 | return null; 25 | } 26 | 27 | public void showSummary() 28 | { 29 | //TODO implement 30 | } 31 | 32 | public void enrollToCourse( String studentId, Course course ) 33 | { 34 | if ( students.containsKey( studentId ) ) 35 | { 36 | students.get( studentId ).enrollToCourse( course ); 37 | } 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/com/generation/utils/PrinterHelper.java: -------------------------------------------------------------------------------- 1 | package com.generation.utils; 2 | 3 | import com.generation.model.Student; 4 | 5 | import java.text.DateFormat; 6 | import java.text.ParseException; 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | import java.util.Scanner; 10 | 11 | public class PrinterHelper 12 | { 13 | 14 | public static void showMainMenu(){ 15 | System.out.println( "|-------------------------------|" ); 16 | System.out.println( "| Welcome to StudentGen |" ); 17 | System.out.println( "|-------------------------------|" ); 18 | System.out.println( "| Select 1 option: |" ); 19 | System.out.println( "| . 1 Register Student |" ); 20 | System.out.println( "| . 2 Find Student |" ); 21 | System.out.println( "| . 3 Enroll Student to Course |" ); 22 | System.out.println( "| . 4 Show Students Summary |" ); 23 | System.out.println( "| . 5 Show Courses Summary |" ); 24 | System.out.println( "| . 6 Exit |" ); 25 | System.out.println( "|-------------------------------|" ); 26 | } 27 | 28 | public static Student createStudentMenu( Scanner scanner ) 29 | throws ParseException 30 | { 31 | System.out.println( "|-------------------------------------|" ); 32 | System.out.println( "| . 1 Register Student |" ); 33 | System.out.println( "|-------------------------------------|" ); 34 | System.out.println( "| Enter student name: |" ); 35 | String name = scanner.next(); 36 | System.out.println( "| Enter student ID: |" ); 37 | String id = scanner.next(); 38 | System.out.println( "| Enter student email: |" ); 39 | String email = scanner.next(); 40 | System.out.println( "| Enter student birth date(mm/dd/yyyy)|" ); 41 | DateFormat formatter = new SimpleDateFormat( "MM/dd/yyyy"); 42 | //TODO validate date format and catch exception to avoid crash 43 | Date birthDate = formatter.parse( scanner.next()); 44 | System.out.println( "|-------------------------------------|" ); 45 | Student student = new Student( id, name, email, birthDate ); 46 | System.out.println( "Student Successfully Registered! " ); 47 | System.out.println(student); 48 | return student; 49 | } 50 | 51 | } 52 | --------------------------------------------------------------------------------