dgPadBootcamps / Java-Bootcamp-2024

1 stars 0 forks source link

Task 3 : Student management system with courses #157

Open mohammad-fahs opened 2 months ago

mohammad-fahs commented 2 months ago

Objective

The goal of this task is to build a simple Student Management System using Spring Boot, where each student has a list of courses. Students will implement APIs to manage students and their courses without using a database, storing data in-memory using ArrayList.

Requirements

  1. Student Class:
    • Each student should have the following attributes:
      • id: A unique identifier for the student (e.g., Long).
      • name: The student's name (e.g., String).
      • email: The student's email address (e.g., String).
      • courses: A list of courses the student is enrolled in (e.g., List<String>).
  2. Course Class
    1. Each class should have the following attributes:
      • id: A unique identifier for the student (e.g., Long).
      • name: The student's name (e.g., String).
      • teacher: the course instructor (e.g., String).
      • credits: the course credits (e.g., Integer)
  3. Course Management:
    • Implement functionality to add and remove courses for a student.
  4. Service Class:
    • Create a StudentService class that contains business logic for managing students and their courses using an ArrayList to store the students.
  5. Controller Class:
    • Create a StudentController class to handle HTTP requests and interact with the StudentService.
  6. APIs: Implement the following APIs and test them using Postman:
    • Create a Student:
      • Method: POST
      • Endpoint: /students
      • Request Body: JSON object with name and email.
      • Response: Created student with id, name, email, and an empty list of courses.
    • Get All Students:
      • Method: GET
      • Endpoint: /students
      • Response: A list of all students.
    • Get a Student by ID:
      • Method: GET
      • Endpoint: /students/{id}
      • Response: The student with the specified id, including their list of courses.
    • Update a Student's Details:
      • Method: PUT
      • Endpoint: /students/{id}
      • Request Body: JSON object with name and email.
      • Response: The updated student information.
    • Delete a Student:
      • Method: DELETE
      • Endpoint: /students/{id}
      • Response: A confirmation that the student was deleted.
    • Add a Course to a Student: (student can has a maximum of 17 credit)
      • Method: POST
      • Endpoint: /students/{id}/courses
      • Request Body: JSON object with courseName.
      • Response: The updated list of courses for the student.
    • Remove a Course from a Student:
      • Method: DELETE
      • Endpoint: /students/{id}/courses
      • Request Body: JSON object with courseName.
      • Response: The updated list of courses for the student.
    • Create a Course:
      • Method: POST
      • Endpoint: /courses
    • Get All Courses:
      • Method: GET
      • Endpoint: /courses
      • Response: A list of all courses.
    • Get a Course by ID:
      • Method: GET
      • Endpoint: /courses/{courseId}
      • Response: The course with the specified courseId.
    • Update a Course's Details:
      • Method: PUT
      • Endpoint: /courses/{courseId}
    • Delete a Course:
      • Method: DELETE
      • Endpoint: /courses/{courseId}
      • Response: A confirmation that the course was deleted.
  7. In-Memory Storage:
    • Use an ArrayList in the StudentService class to store the list of students. No database is required for this task.

Instructions

  1. Project Setup:
    • Use Spring Initializr or your IDE to create a Spring Boot project with the Web dependency.
  2. Implement the Student Class:
    • Create a Student class with the required attributes and methods (e.g., constructors, getters, and setters).
  3. Implement the StudentService Class:
    • Create a StudentService class that handles the business logic for managing students and their courses.
  4. Implement the StudentController Class:
    • Create a StudentController class to map the APIs to their respective service methods.
  5. Test the APIs:
    • Use Postman to test all the implemented APIs, ensuring they work as expected.

Example Scenario

create a simple scenario to add list of courses, list of students with set of courses, in case the student had more than 17 course let the operation fail,

update courses and remove some courses and list them

Submission

Submit the completed project files along with a Postman screenshots containing the API requests and response . Include screenshots of successful API responses in Postman as evidence of testing.

Ali-Khalil0 commented 2 months ago

[

Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image