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
6 changes: 6 additions & 0 deletions Final Project-solution/Final Project/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="out/production/JAVA-13 - Final Project"/>
</classpath>
2 changes: 2 additions & 0 deletions Final Project-solution/Final Project/.idea/.gitignore

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

5 changes: 5 additions & 0 deletions Final Project-solution/Final Project/.idea/misc.xml

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

8 changes: 8 additions & 0 deletions Final Project-solution/Final Project/.idea/modules.xml

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

6 changes: 6 additions & 0 deletions Final Project-solution/Final Project/.idea/vcs.xml

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

28 changes: 28 additions & 0 deletions Final Project-solution/Final Project/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Final Project</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1691943444192</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
11 changes: 11 additions & 0 deletions Final Project-solution/Final Project/JAVA-13 - Final Project.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
87 changes: 87 additions & 0 deletions Final Project-solution/Final Project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

<img align="right" width="150" height="150" src="https://media-exp1.licdn.com/dms/image/C4E0BAQF7BYCCZt5epw/company-logo_200_200/0?e=2159024400&v=beta&t=qUAFP9bUgBEEXGVQYpUXW1J_OiP8e0r4rFBpqp8OrxA">

# Java Programming Fundamentals - Assessment

<br/>
<br/>
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<Course> 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<Course> 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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
145 changes: 145 additions & 0 deletions Final Project-solution/Final Project/src/com/generation/Main.java
Original file line number Diff line number Diff line change
@@ -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 );
}
}
Original file line number Diff line number Diff line change
@@ -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 + '}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.generation.model;

import java.util.List;

public interface Evaluation
{
double getAverage();

List<Course> getApprovedCourses();

}
Loading