diff --git a/Final Project-solution/Final Project/.classpath b/Final Project-solution/Final Project/.classpath new file mode 100644 index 0000000..13a3ce1 --- /dev/null +++ b/Final Project-solution/Final Project/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Final Project-solution/Final Project/.idea/.gitignore b/Final Project-solution/Final Project/.idea/.gitignore new file mode 100644 index 0000000..5c98b42 --- /dev/null +++ b/Final Project-solution/Final Project/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/Final Project-solution/Final Project/.idea/misc.xml b/Final Project-solution/Final Project/.idea/misc.xml new file mode 100644 index 0000000..53f706d --- /dev/null +++ b/Final Project-solution/Final Project/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Final Project-solution/Final Project/.idea/modules.xml b/Final Project-solution/Final Project/.idea/modules.xml new file mode 100644 index 0000000..0a75983 --- /dev/null +++ b/Final Project-solution/Final Project/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Final Project-solution/Final Project/.idea/vcs.xml b/Final Project-solution/Final Project/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Final Project-solution/Final Project/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Final Project-solution/Final Project/.project b/Final Project-solution/Final Project/.project new file mode 100644 index 0000000..8119a44 --- /dev/null +++ b/Final Project-solution/Final Project/.project @@ -0,0 +1,28 @@ + + + Final Project + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + 1691943444192 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/Final Project-solution/Final Project/JAVA-13 - Final Project.iml b/Final Project-solution/Final Project/JAVA-13 - Final Project.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Final Project-solution/Final Project/JAVA-13 - Final Project.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Final Project-solution/Final Project/README.md b/Final Project-solution/Final Project/README.md new file mode 100644 index 0000000..cfc0c28 --- /dev/null +++ b/Final Project-solution/Final Project/README.md @@ -0,0 +1,87 @@ + + + +# Java Programming Fundamentals - Assessment + +
+
+ It's time to see how much you learned about Java and Object Oriented Programming. + + ## Part 1: Understanding the StudentGen project + 1. Download the source code and import the project using IntelliJ Idea or any other IDE you prefer. + 2. Understand the project stucture: + * Packages + * Classes + * Functionality + 3. Run and test the project to get a deeper undertanding of how it works (remember the persistence mindset!). + + ## Part 2: Implementing the Student and StudentService missing features + 1. Open the *Student* class (`src/com/generation/model/Student.java`) and implement the following methods: + + ```java + public void enrollToCourse( Course course ) + { + //TODO implement this method + } + + public boolean isCourseApproved( String courseCode ) + { + //TODO implement this method + return false; + } + + public boolean isAttendingCourse( String courseCode ) + { + //TODO implement this method + return false; + } + @Override + public List getApprovedCourses() + { + //TODO implement this method + return null; + } + ``` + + 2. Open the *StudentService* class (`src/com/generation/service/StudentService.java`) and implement the following methods: + + ```java + public boolean isSubscribed( String studentId ) + { + //TODO implement this method + return false; + } + + public void showSummary() + { + //TODO implement + } + ``` + + Hint: To show the summary use `System.out.println()` to print out to the console. + + ## Part 3: Implementing the missing main method features + + 1. Implement the method to *gradeStudent( StudentService studentService, Scanner scanner )* in `src/com/generation/Main.java ` to have a fully functional program. + + 2. Test the program to verify it works as expected: + * Create a new student. + * Enrroll the student to few courses. + * Grade the student. + * Show the students and courses summary and verify that data is correct. + + + ## Part 4: Handling exceptions + 1. Register a new user providing a wrong date format. + 2. Modify the createStudentMenu so it handles correctly the exception when a wrong date format is inserted by the user. + 3. Catch the exception and show a proper message to the user. + + ## Part 5: Writing Unit Tests + 1. Write 2 Unit tests for the class *StudentService* + 2. Write 2 Unit tests for the class *CourseService* + + + ## Challenge Yourself + 1. Implement a way to store grades for each course a student is taking. There should be a way to update/set the score. + Afterwards, fill in the `public List findPassedCourses( Course course )` method in Student.java + 2. Implement an additional feature in the menu options that will display the average grade of all the students suscribed to a given course. diff --git a/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/Main.class b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/Main.class new file mode 100644 index 0000000..a1560b6 Binary files /dev/null and b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/Main.class differ diff --git a/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Course.class b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Course.class new file mode 100644 index 0000000..f852dc8 Binary files /dev/null and b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Course.class differ diff --git a/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Evaluation.class b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Evaluation.class new file mode 100644 index 0000000..fcf2c79 Binary files /dev/null and b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Evaluation.class differ diff --git a/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Instructor.class b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Instructor.class new file mode 100644 index 0000000..3c997a4 Binary files /dev/null and b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Instructor.class differ diff --git a/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Module.class b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Module.class new file mode 100644 index 0000000..456b179 Binary files /dev/null and b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Module.class differ diff --git a/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Person.class b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Person.class new file mode 100644 index 0000000..0160baa Binary files /dev/null and b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Person.class differ diff --git a/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Student.class b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Student.class new file mode 100644 index 0000000..d6ee55b Binary files /dev/null and b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Student.class differ diff --git a/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/CourseService.class b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/CourseService.class new file mode 100644 index 0000000..a0ab4b0 Binary files /dev/null and b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/CourseService.class differ diff --git a/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/StudentService.class b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/StudentService.class new file mode 100644 index 0000000..256a193 Binary files /dev/null and b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/StudentService.class differ diff --git a/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/utils/PrinterHelper.class b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/utils/PrinterHelper.class new file mode 100644 index 0000000..978e377 Binary files /dev/null and b/Final Project-solution/Final Project/out/production/JAVA-13 - Final Project/com/generation/utils/PrinterHelper.class differ diff --git a/Final Project-solution/Final Project/src/com/generation/Main.java b/Final Project-solution/Final Project/src/com/generation/Main.java new file mode 100644 index 0000000..9ce364a --- /dev/null +++ b/Final Project-solution/Final Project/src/com/generation/Main.java @@ -0,0 +1,145 @@ +package com.generation; + +import com.generation.model.Course; +import com.generation.model.Student; +import com.generation.service.CourseService; +import com.generation.service.StudentService; +import com.generation.utils.PrinterHelper; + +import java.text.ParseException; +import java.util.Objects; +import java.util.Scanner; + +public class Main +{ + + public static void main( String[] args ) + throws ParseException + { + StudentService studentService = new StudentService(); + CourseService courseService = new CourseService(); + Scanner scanner = new Scanner( System.in ); + int option = 0; + do + { + PrinterHelper.showMainMenu(); + option = scanner.nextInt(); + switch ( option ) + { + case 1: + registerStudent( studentService, scanner ); + break; + case 2: + findStudent( studentService, scanner ); + break; + case 3: + gradeStudent( studentService, scanner ); + break; + case 4: + enrollStudentToCourse( studentService, courseService, scanner ); + break; + case 5: + showStudentsSummary( studentService, scanner ); + break; + case 6: + showCoursesSummary( courseService, scanner ); + break; + } + } + while ( option != 7 ); + } + + private static void enrollStudentToCourse( StudentService studentService, CourseService courseService, + Scanner scanner ) + { + System.out.println( "Insert student ID" ); + String studentId = scanner.next(); + Student student = studentService.findStudent( studentId ); + if ( student == null ) + { + System.out.println( "Invalid Student ID" ); + return; + } + System.out.println( student ); + System.out.println( "Insert course ID" ); + String courseId = scanner.next(); + Course course = courseService.getCourse( courseId ); + if ( course == null ) + { + System.out.println( "Invalid Course ID" ); + return; + } + System.out.println( course ); + courseService.enrollStudent( courseId, student ); + studentService.enrollToCourse( studentId, course ); + System.out.println( "Student with ID: " + studentId + " enrolled successfully to " + courseId ); + + } + + private static void showCoursesSummary( CourseService courseService, Scanner scanner ) + { + courseService.showSummary(); + } + + private static void showStudentsSummary( StudentService studentService, Scanner scanner ) + { + studentService.showSummary(); + } + + private static void gradeStudent( StudentService studentService, Scanner scanner ) //heavily modified + { + System.out.println("Enter Student Id --> "); + String sid = scanner.next(); + + if(studentService.isSubscribed(sid)){ + Student s = studentService.findStudent(sid); + System.out.println("Enter the courseId --> "); + String courseId = scanner.next(); + + System.out.println("Enter credits --> "); + double cred = scanner.nextDouble(); + + if(s.isAttendingCourse(courseId) && s.isCourseApproved(courseId)){ + for(Course c : s.getApprovedCourses()){ + if(Objects.equals(c.getCode(), courseId)){ + System.out.println("student " + sid + " awarded " + cred + " credits for course ID " + courseId); + if(cred >= c.getCredits()) { + s.findPassedCourses(c); + System.out.println("Student Passed the subject"); + }else{ + System.out.println("Not Enough Credits to pass the subject."); + } + } + } + }else{ + System.out.println("Not enrolled in this course or course not approved."); + } + + }else{ + System.out.println("Student is not subscribed."); + } + } + + private static void findStudent( StudentService studentService, Scanner scanner ) + { + System.out.println( "Enter student ID: " ); + String studentId = scanner.next(); + Student student = studentService.findStudent( studentId ); + if ( student != null ) + { + System.out.println( "Student Found: " ); + System.out.println( student ); + } + else + { + System.out.println( "Student with Id = " + studentId + " not found" ); + } + } + + private static void registerStudent( StudentService studentService, Scanner scanner ) + throws ParseException + { + Student student = PrinterHelper.createStudentMenu( scanner ); + studentService.subscribeStudent( student ); + } +} diff --git a/Final Project-solution/Final Project/src/com/generation/model/Course.java b/Final Project-solution/Final Project/src/com/generation/model/Course.java new file mode 100644 index 0000000..1512a63 --- /dev/null +++ b/Final Project-solution/Final Project/src/com/generation/model/Course.java @@ -0,0 +1,48 @@ +package com.generation.model; + +public class Course +{ + private final String code; + + private final String name; + + private final int credits; + + private final Module module; + + + public Course( String code, String name, int credits, Module module ) + { + this.code = code; + this.name = name; + this.credits = credits; + this.module = module; + } + + public String getCode() + { + return code; + } + + public String getName() + { + return name; + } + + public int getCredits() + { + return credits; + } + + public Module getModule() + { + return module; + } + + @Override + public String toString() + { + return "Course{" + "code='" + code + '\'' + ", name='" + name + '\'' + ", credits=" + credits + ", module=" + + module + '}'; + } +} diff --git a/Final Project-solution/Final Project/src/com/generation/model/Evaluation.java b/Final Project-solution/Final Project/src/com/generation/model/Evaluation.java new file mode 100644 index 0000000..c218045 --- /dev/null +++ b/Final Project-solution/Final Project/src/com/generation/model/Evaluation.java @@ -0,0 +1,11 @@ +package com.generation.model; + +import java.util.List; + +public interface Evaluation +{ + double getAverage(); + + List getApprovedCourses(); + +} diff --git a/Final Project-solution/Final Project/src/com/generation/model/Instructor.java b/Final Project-solution/Final Project/src/com/generation/model/Instructor.java new file mode 100644 index 0000000..9dccdfa --- /dev/null +++ b/Final Project-solution/Final Project/src/com/generation/model/Instructor.java @@ -0,0 +1,29 @@ +package com.generation.model; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class Instructor + extends Person +{ + + private int experienceMonths; + + private final List teachingCourses = new ArrayList<>(); + + protected Instructor( String id, String name, String email, Date birthDate ) + { + super( id, name, email, birthDate ); + } + + public int getExperienceMonths() + { + return experienceMonths; + } + + public void setExperienceMonths( int experienceMonths ) + { + this.experienceMonths = experienceMonths; + } +} diff --git a/Final Project-solution/Final Project/src/com/generation/model/Module.java b/Final Project-solution/Final Project/src/com/generation/model/Module.java new file mode 100644 index 0000000..cf20d3c --- /dev/null +++ b/Final Project-solution/Final Project/src/com/generation/model/Module.java @@ -0,0 +1,54 @@ +package com.generation.model; + +import java.util.HashMap; +import java.util.Map; + +public class Module +{ + private final String code; + + private final String name; + + private final String description; + + private final Map prerequisites = new HashMap<>(); + + public Module( String code, String name, String description ) + { + this.code = code; + this.name = name; + this.description = description; + } + + public void addPrerequisite( Module module ) + { + prerequisites.put( module.code, module ); + } + + + public String getCode() + { + return code; + } + + public String getName() + { + return name; + } + + public String getDescription() + { + return description; + } + + public Map getPrerequisites() + { + return prerequisites; + } + + @Override + public String toString() + { + return "Module{" + "name='" + name + '\'' + '}'; + } +} diff --git a/Final Project-solution/Final Project/src/com/generation/model/Person.java b/Final Project-solution/Final Project/src/com/generation/model/Person.java new file mode 100644 index 0000000..56cb7fd --- /dev/null +++ b/Final Project-solution/Final Project/src/com/generation/model/Person.java @@ -0,0 +1,48 @@ +package com.generation.model; + +import java.util.Date; + +abstract public class Person +{ + private final String id; + + private final String name; + + private final String email; + + private final Date birthDate; + + protected Person( String id, String name, String email, Date birthDate ) + { + this.id = id; + this.name = name; + this.email = email; + this.birthDate = birthDate; + } + + public String getId() + { + return id; + } + + public String getName() + { + return name; + } + + public String getEmail() + { + return email; + } + + public Date getBirthDate() + { + return birthDate; + } + + @Override + public String toString() + { + return id + '\'' + ", name='" + name + '\'' + ", email='" + email + '\'' + ", birthDate=" + birthDate; + } +} diff --git a/Final Project-solution/Final Project/src/com/generation/model/Student.java b/Final Project-solution/Final Project/src/com/generation/model/Student.java new file mode 100644 index 0000000..b8d877c --- /dev/null +++ b/Final Project-solution/Final Project/src/com/generation/model/Student.java @@ -0,0 +1,83 @@ +package com.generation.model; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Student + extends Person + implements Evaluation +{ + private double average; + + private final List courses = new ArrayList<>(); + public List passed = new ArrayList<>(); + public final Map approvedCourses = new HashMap<>(); //private -> public + + public Student( String id, String name, String email, Date birthDate ) + { + super( id, name, email, birthDate ); + } + + public void enrollToCourse( Course course ) + { + //TODO implement this method + registerApprovedCourse(course); + courses.add(course); + } + + public void registerApprovedCourse( Course course ) + { + approvedCourses.put( course.getCode(), course ); + } + + public boolean isCourseApproved( String courseCode ) + { + //TODO implement this method + return approvedCourses.containsKey(courseCode); + } + + // CHALLENGE IMPLEMENTATION: Read README.md to find instructions on how to solve. + public void findPassedCourses(Course course ) // made this method void + { + //TODO implement this method + passed.add(course); + } + + public boolean isAttendingCourse( String courseCode ) + { + //TODO implement this method + for(Course c : courses){ + if(c.getCode().equals(courseCode)) return true; + } + return false; + } + + @Override + public double getAverage() + { + for (Course course : passed) { + average += course.getCredits(); + } + return average/ passed.size(); + } + + @Override + public List getApprovedCourses() + { + //TODO implement this method + List Approved = new ArrayList<>(); + for (String key : approvedCourses.keySet()) { + Approved.add(approvedCourses.get(key)); + } + return Approved; + } + + @Override + public String toString() + { + return "Student {" + super.toString() + "}"; + } +} diff --git a/Final Project-solution/Final Project/src/com/generation/service/CourseService.java b/Final Project-solution/Final Project/src/com/generation/service/CourseService.java new file mode 100644 index 0000000..24df98b --- /dev/null +++ b/Final Project-solution/Final Project/src/com/generation/service/CourseService.java @@ -0,0 +1,98 @@ +package com.generation.service; + +import com.generation.model.Course; +import com.generation.model.Module; +import com.generation.model.Student; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class CourseService +{ + private final Map courses = new HashMap<>(); + + private final Map> enrolledStudents = new HashMap<>(); + + public CourseService() + { + Module module = new Module( "INTRO-CS", "Introduction to Computer Science", + "Introductory module for the generation technical programs" ); + registerCourse( new Course( "INTRO-CS-1", "Introduction to Computer Science", 9, module ) ); + registerCourse( new Course( "INTRO-CS-2", "Introduction to Algorithms", 9, module ) ); + registerCourse( new Course( "INTRO-CS-3", "Algorithm Design and Problem Solving - Introduction ", 9, module ) ); + registerCourse( new Course( "INTRO-CS-4", "Algorithm Design and Problem Solving - Advanced", 9, module ) ); + registerCourse( new Course( "INTRO-CS-5", "Terminal Fundamentals", 9, module ) ); + registerCourse( new Course( "INTRO-CS-6", "Source Control Using Git and Github", 9, module ) ); + registerCourse( new Course( "INTRO-CS-7", "Agile Software Development with SCRUM", 9, module ) ); + + Module moduleWebFundamentals = new Module( "INTRO-WEB", "Web Development Fundamentals", + "Introduction to fundamentals of web development" ); + registerCourse( new Course( "INTRO-WEB-1", "Introduction to Web Applications", 9, moduleWebFundamentals ) ); + registerCourse( new Course( "INTRO-WEB-2", "Introduction to HTML", 9, moduleWebFundamentals ) ); + registerCourse( new Course( "INTRO-WEB-3", "Introduction to CSS", 9, moduleWebFundamentals ) ); + registerCourse( new Course( "INTRO-WEB-4", "Advanced HTML", 9, moduleWebFundamentals ) ); + registerCourse( new Course( "INTRO-WEB-5", "Advanced CSS", 9, moduleWebFundamentals ) ); + registerCourse( new Course( "INTRO-WEB-6", "Introduction to Bootstrap Framework", 9, moduleWebFundamentals ) ); + registerCourse( + new Course( "INTRO-WEB-7", "Introduction to JavaScript for Web Development", 9, moduleWebFundamentals ) ); + + } + + public void registerCourse( Course course ) + { + courses.put( course.getCode(), course ); + } + + public Course getCourse( String code ) + { + if ( courses.containsKey( code ) ) + { + return courses.get( code ); + } + return null; + } + + public void enrollStudent( String courseId, Student student ) + { + if ( !enrolledStudents.containsKey( courseId ) ) + { + enrolledStudents.put( courseId, new ArrayList<>() ); + } + enrolledStudents.get( courseId ).add( student ); + } + + public void showEnrolledStudents( String courseId ) + { + if ( enrolledStudents.containsKey( courseId ) ) + { + List students = enrolledStudents.get( courseId ); + for ( Student student : students ) + { + System.out.println( student ); + } + } + } + + + public void showSummary() + { + System.out.println( "Available Courses:" ); + for ( String key : courses.keySet() ) + { + Course course = courses.get( key ); + System.out.println( course ); + } + System.out.println( "Enrolled Students" ); + for ( String key : enrolledStudents.keySet() ) + { + List students = enrolledStudents.get( key ); + System.out.println( "Students on Course " + key + ": " ); + for ( Student student : students ) + { + System.out.println( student ); + } + } + } +} diff --git a/Final Project-solution/Final Project/src/com/generation/service/StudentService.java b/Final Project-solution/Final Project/src/com/generation/service/StudentService.java new file mode 100644 index 0000000..f8845f6 --- /dev/null +++ b/Final Project-solution/Final Project/src/com/generation/service/StudentService.java @@ -0,0 +1,73 @@ +package com.generation.service; + +import com.generation.model.Course; +import com.generation.model.Student; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class StudentService +{ + private final Map students = new HashMap<>(); + + public void subscribeStudent( Student student ) + { + students.put( student.getId(), student ); + } + + public Student findStudent( String studentId ) + { + if ( students.containsKey( studentId ) ) + { + return students.get( studentId ); + } + return null; + } + + public boolean isSubscribed( String studentId ) + { + //TODO implement this method + return students.containsKey(studentId); + } + + public void showSummary() + { + //TODO implement + System.out.println("-------------Student Summary -----------------------------------\n"); + + for(String s : students.keySet()){ + if(isSubscribed(s)){ + System.out.println("Name : " + students.get(s).getName()); + System.out.println("DOB : " + students.get(s).getBirthDate()); + System.out.println("ID : " + students.get(s).getId()); + System.out.println("Email : " + students.get(s).getEmail()); + System.out.println("Enrolled Courses : " + students.get(s).getApprovedCourses().size()); + for(Course c : students.get(s).getApprovedCourses()){ + System.out.println(c.toString()); + } + + System.out.println("Passed Courses : " + students.get(s).passed.size()); + for(Course c : students.get(s).passed){ + System.out.println(c.toString()); + } + + System.out.println("Average Credits : " + students.get(s).getAverage()); + } + System.out.println("--------------------------------------"); + System.out.println(); + } + + } + + public void enrollToCourse( String studentId, Course course ) + { + if ( students.containsKey( studentId ) ) + { + students.get( studentId ).enrollToCourse( course ); + } + } + + +} diff --git a/Final Project-solution/Final Project/src/com/generation/utils/PrinterHelper.java b/Final Project-solution/Final Project/src/com/generation/utils/PrinterHelper.java new file mode 100644 index 0000000..a71de5a --- /dev/null +++ b/Final Project-solution/Final Project/src/com/generation/utils/PrinterHelper.java @@ -0,0 +1,66 @@ +package com.generation.utils; + +import com.generation.model.Student; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Scanner; + +public class PrinterHelper +{ + + public static void showMainMenu(){ + System.out.println( "|-------------------------------|" ); + System.out.println( "| Welcome to StudentGen |" ); + System.out.println( "|-------------------------------|" ); + System.out.println( "| Select 1 option: |" ); + System.out.println( "| . 1 Register Student |" ); + System.out.println( "| . 2 Find Student |" ); + System.out.println( "| . 3 Grade Student |" ); + System.out.println( "| . 4 Enroll Student to Course |" ); + System.out.println( "| . 5 Show Students Summary |" ); + System.out.println( "| . 6 Show Courses Summary |" ); + System.out.println( "| . 7 Exit |" ); + System.out.println( "|-------------------------------|" ); + System.out.println("Select an action : "); + } + + public static Student createStudentMenu( Scanner scanner ) { + System.out.println( "|-------------------------------------|" ); + System.out.println( "| . 1 Register Student |" ); + System.out.println( "|-------------------------------------|" ); + System.out.println( "| Enter student name: |" ); + String name = scanner.next(); + System.out.println( "| Enter student ID: |" ); + String id = scanner.next(); + System.out.println( "| Enter student email: |" ); + String email = scanner.next(); + + DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); + Date birthDate = null; + + boolean validInput = false; + + while (!validInput) { + System.out.println("| Enter student birth date (dd/MM/yyyy)|"); + String inputDate = scanner.next(); + + try { + birthDate = formatter.parse(inputDate); + validInput = true; + } catch (ParseException e) { + System.out.println("Invalid date format. Please enter a date in the format (dd/MM/yyyy)."); + } + } + + + System.out.println( "|-------------------------------------|" ); + Student student = new Student( id, name, email, birthDate ); + System.out.println( "Student Successfully Registered! " ); + System.out.println(student); + return student; + } + +} diff --git a/Final Project/.classpath b/Final Project/.classpath new file mode 100644 index 0000000..13a3ce1 --- /dev/null +++ b/Final Project/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Final Project/.project b/Final Project/.project new file mode 100644 index 0000000..2f13316 --- /dev/null +++ b/Final Project/.project @@ -0,0 +1,28 @@ + + + JAVA-GenerationIndia-Solution_Final Project + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + 1691943444206 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/Final Project/out/production/JAVA-13 - Final Project/com/generation/Main.class b/Final Project/out/production/JAVA-13 - Final Project/com/generation/Main.class index 6ad6a79..0e9302a 100644 Binary files a/Final Project/out/production/JAVA-13 - Final Project/com/generation/Main.class and b/Final Project/out/production/JAVA-13 - Final Project/com/generation/Main.class differ diff --git a/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Course.class b/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Course.class index 956d4bd..f852dc8 100644 Binary files a/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Course.class and b/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Course.class differ diff --git a/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Evaluation.class b/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Evaluation.class index 3b0397b..fcf2c79 100644 Binary files a/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Evaluation.class and b/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Evaluation.class differ diff --git a/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Instructor.class b/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Instructor.class index b998a6f..3c997a4 100644 Binary files a/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Instructor.class and b/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Instructor.class differ diff --git a/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Module.class b/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Module.class index b5b80f6..456b179 100644 Binary files a/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Module.class and b/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Module.class differ diff --git a/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Person.class b/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Person.class index f17ab54..0160baa 100644 Binary files a/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Person.class and b/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Person.class differ diff --git a/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Student.class b/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Student.class index facd152..f3cd562 100644 Binary files a/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Student.class and b/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Student.class differ diff --git a/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/CourseService.class b/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/CourseService.class index 7e164c5..a0ab4b0 100644 Binary files a/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/CourseService.class and b/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/CourseService.class differ diff --git a/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/StudentService.class b/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/StudentService.class index f619ce1..440328b 100644 Binary files a/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/StudentService.class and b/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/StudentService.class differ diff --git a/Final Project/out/production/JAVA-13 - Final Project/com/generation/utils/PrinterHelper.class b/Final Project/out/production/JAVA-13 - Final Project/com/generation/utils/PrinterHelper.class index 472644b..142f7db 100644 Binary files a/Final Project/out/production/JAVA-13 - Final Project/com/generation/utils/PrinterHelper.class and b/Final Project/out/production/JAVA-13 - Final Project/com/generation/utils/PrinterHelper.class differ diff --git a/Loops/Loops Solution/Table.java b/Loops/Loops Solution/Table.java new file mode 100644 index 0000000..04bb247 --- /dev/null +++ b/Loops/Loops Solution/Table.java @@ -0,0 +1,21 @@ +import java.util.Scanner; + + public class Table + { + public static void main(String[] args) + { + Scanner console = new Scanner(System.in); + int num; + + System.out.print("Enter any positive integer: "); + num = console.nextInt(); + + System.out.println("Multiplication Table of " + num); + int i=1; + //TODO implement While loop to get print result + while( i <= 10){ + System.out.println(num+" "+"*"+" "+i+" "+ "="+" " +i*num); + i++; + } + } + } \ No newline at end of file diff --git a/README.md b/README.md index 6cc1fce..a37f7c3 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,4 @@ # Java Programming Fundamentals Practice Exercises for the Java Programming Fundamentals module developed by Generation. +vcvgcgv \ No newline at end of file