Project: Attendance Management Project — Part 1
Student: Your Full Name
Squad: SXX
Part 1: Project setup and a small Java app demonstrating encapsulation using a Student class and a Main program.
From project root:
javac src/com/school/Student.java src/com/school/Main.java
java -cp src com.school.Main
## Part-02 — Core Domain Modelling
This part introduces `Student` and `Course` domain classes and demonstrates managing them using arrays.
### How to compile & run
```bash
javac src/com/school/*.java
java -cp src com.school.Main
## Part-03 — Constructor Initialization & Auto-ID Generation
This part implements constructors for `Student` and `Course` and adds automatic unique ID generation using static counters.
### What changed
- `Student` now auto-generates integer IDs (studentId) using `nextStudentIdCounter` and constructors `Student(String name)` and `Student(String name, int age, double attendancePercent)`.
- `Course` now auto-generates integer IDs (courseId) starting at 101 using `nextCourseIdCounter` and constructors `Course(String courseName)` and `Course(String courseName, String instructor, int maxStudents)`.
- `Course` `toString()` prints the id prefixed with `C` (e.g., `C101`).
### How to compile & run
From project root:
```bash
javac src/com/school/*.java
java -cp src com.school.Main
## Part-04 — Data Encapsulation & Attendance Recording Validation
This part applies encapsulation to `Student` and `Course` (private fields + public getters)
and adds `AttendanceRecord` to store attendance with validation.
- `AttendanceRecord(int studentId, int courseId, String status)` validates `status`.
- Accepts "Present" or "Absent" (case-insensitive).
- Any other value becomes "Invalid" and prints a warning.
How to compile & run:
```bash
javac src/com/school/*.java
java -cp src com.school.Main
## Part-05 — Establishing Students, Teaching & Non-Teaching Staff hierarchy
- Added `Person.java` (base class) with `id`, `name`, and a universal auto-ID generator.
- Implemented `Student`, `Teacher`, and `Staff` classes that extend `Person`.
- Each subclass overrides `displayDetails()` to print role-specific information.
- `Main.java` demonstrates creation and display of Student, Teacher, and Staff objects and uses `student.getId()` in `AttendanceRecord`.
How to compile & run:
```bash
javac src/com/school/*.java
java -cp src com.school.Main
### Files generated by Part-06
- `students.txt` (CSV: id,name,gradeLevel)
- `courses.txt` (CSV: courseId,courseName)
- `attendance_log.txt` (CSV: studentId,courseId,status)
How to run:
1. Compile: `javac src/com/school/*.java`
2. Run: `java -cp src com.school.Main`
3. Verify files `students.txt`, `courses.txt`, `attendance_log.txt` appear in the project root.
## Part 7: Polymorphic Behaviour in Attendance and Displaying Reports
- Modified `AttendanceRecord` to hold `Student` and `Course` objects instead of just their IDs, enhancing its object-oriented nature and how records are displayed. The `toDataString()` method still uses IDs for simpler file storage.
- Created a `displaySchoolDirectory(List<Person> people)` method in `Main.java` to demonstrate polymorphism. This method iterates through a list of `Person` objects (containing `Student`, `Teacher`, `Staff` instances) and calls `person.displayDetails()`. The correct overridden method for each specific object type is executed at runtime.
- Populated a `List<Person>` in `main` and used it with `displaySchoolDirectory`.
- Updated `Main.java` to use `instanceof` and casting when preparing the list of students for saving, as `Person` itself does not implement `Storable`.
- Discussed how polymorphism allows for flexible and extensible code by treating different object types uniformly through a common interface or base class reference.
### How to Run
1. Navigate to the project root directory.
2. Compile: `javac src/com/school/*.java`
3. Run: `java -cp src com.school.Main`
## Part 8: Overloaded Commands: Multiple Ways to Mark and Query Attendance
- Created an `AttendanceService.java` class to encapsulate attendance logic and manage the list of `AttendanceRecord` objects.
- Implemented overloaded `markAttendance` methods in `AttendanceService`:
- `markAttendance(Student student, Course course, String status)`
- `markAttendance(int studentId, int courseId, String status, List<Student> allStudents, List<Course> allCourses)` (performs lookups)
- Implemented overloaded `displayAttendanceLog` methods in `AttendanceService`:
- `displayAttendanceLog()` (shows all records)
- `displayAttendanceLog(Student student)` (filters by student)
- `displayAttendanceLog(Course course)` (filters by course)
- Utilized Java Streams for filtering records in the specific display methods.
- `AttendanceService` now uses `FileStorageService` to save its `attendanceLog`.
- Demonstrated the use of these overloaded methods in `Main.java`, showing how different method signatures allow for flexible ways to call the same conceptual operation.
### How to Run
1. Navigate to the project root directory.
2. Compile: `javac src/com/school/*.java`
3. Run: `java -cp src com.school.Main`
4. Check `attendance_log.txt` for saved records.
## Part 9: SOLID Service Layer: RegistrationService & AttendanceService Separation
- Applied the Single Responsibility Principle (SRP) by creating dedicated service classes.
- Created `RegistrationService.java` to handle the registration, management (lists, lookups), and saving of `Student`, `Teacher`, `Staff`, and `Course` entities.
- Modified `Teacher.java` and `Staff.java` to implement `Storable` for file persistence.
- Refactored `AttendanceService.java`:
- It now depends on `RegistrationService` for looking up students/courses by ID.
- Removed internal lookup helper methods, delegating this to `RegistrationService`.
- Its primary focus is now solely on managing attendance records.
- Updated `Main.java` to act as an orchestrator, instantiating and using these services. Direct entity list management was removed from `Main`.
- Demonstrated improved code organization and clearer separation of concerns.
### How to Run
1. Navigate to the project root directory.
2. Compile: `javac src/com/school/*.java`
3. Run: `java -cp src com.school.Main`
4. Check for `students.txt`, `teachers.txt`, `staff.txt`, `courses.txt`, and `attendance_log.txt`.
## Part 10: Capacity Management & SOLID Principles Reflection
- Added a `capacity` feature to the `Course` class, along with an internal list of `enrolledStudents`.
- Updated `Course.displayDetails()` to show capacity and enrollment count, and `Course.toDataString()` to save capacity.
- Modified `RegistrationService`:
- `createCourse` method now accepts a capacity parameter.
- Added `enrollStudentInCourse(Student student, Course course)` method to handle enrollment logic, checking against course capacity.
- Updated `Main.java` to demonstrate course creation with capacity, student enrollment attempts (including exceeding capacity), and displaying updated course information.
- Discussed how other SOLID principles (like Open-Closed and Dependency Inversion) could be applied for further enhancements and flexibility.
- Concluded the 10-part project, having built a foundational console-based attendance system.
### How to Run
1. Navigate to the project root directory.
2. Compile: `javac src/com/school/*.java`
3. Run: `java -cp src com.school.Main`
4. Check `courses.txt` for the capacity field and other files for their respective data.