- Defined
Student
class withstudentId
,name
,setDetails()
, anddisplayDetails()
method. - Defined
Course
class withcourseId
,courseName
,setDetails()
, anddisplayDetails()
method. - Utilized arrays of objects in
Main.java
to manage and display multiple students and courses. - Introduced basic usage of
this
keyword.
- Navigate to the project root directory.
- Compile:
javac src/com/school/Student.java src/com/school/Course.java src/com/school/Main.java
(orjavac src/com/school/*.java
) - Run:
java -cp src com.school.Main
- Implemented parameterized constructors in
Student
andCourse
classes for object initialization. - Utilized
private static
member variables for automatic and unique ID generation. - Demonstrated the use of the
this
keyword to distinguish instance variables from constructor parameters. - Changed
Course
'scourseId
toint
for simpler auto-generation and updated its display. - Updated
Main.java
to use constructors and show ID progression.
- Navigate to the project root directory.
- Compile:
javac src/com/school/Student.java src/com/school/Course.java src/com/school/Main.java
(orjavac src/com/school/*.java
) - Run:
java -cp src com.school.Main
- Applied encapsulation to
Student
andCourse
classes by making fieldsprivate
and adding publicgetters
. - Introduced a new
AttendanceRecord
class withprivate
fields, a constructor, andgetters
to store attendance data. - Implemented basic validation in the
AttendanceRecord
constructor for the attendance status (allowing only "Present" or "Absent"). - Used an
ArrayList
inMain.java
to store and displayAttendanceRecord
objects. - Demonstrated retrieving IDs using getters (e.g.,
student1.getStudentId()
) when creating records.
- Navigate to the project root directory.
- Compile:
javac src/com/school/*.java
(or list individual files includingAttendanceRecord.java
) - Run:
java -cp src com.school.Main
- Created a base class
Person.java
with common attributes (id
,name
), a universal auto-ID generator, and adisplayDetails()
method. - Modified
Student.java
to inherit fromPerson
, usingsuper()
to call the parent constructor and overridingdisplayDetails()
to add student-specific info (e.g., grade level). - Created
Teacher.java
extendingPerson
, adding asubjectTaught
attribute and its owndisplayDetails()
. - Created
Staff.java
extendingPerson
, adding arole
attribute and its owndisplayDetails()
. - Demonstrated creation and display of
Student
,Teacher
, andStaff
objects inMain.java
. - Updated
AttendanceRecord
creation to use the inheritedgetId()
method.
- Defined a
Storable
interface with atoDataString()
method. - Modified
Student
,Course
, andAttendanceRecord
classes to implement theStorable
interface and provide their specifictoDataString()
implementations (CSV format). - Created a
FileStorageService
class with asaveData(List<? extends Storable> items, String filename)
method to writeStorable
objects to a text file. - Utilized
try-with-resources
for safe file handling (PrintWriter
,FileWriter
). - Demonstrated in
Main.java
how to save lists of students, courses, and attendance records to separate files (students.txt
,courses.txt
,attendance_log.txt
). - Discussed the flexibility provided by interfaces for handling different types of storable objects uniformly.
- Navigate to the project root directory.
- Compile:
javac src/com/school/*.java
- Run:
java -cp src com.school.Main
- Check the generated files:
students.txt
,courses.txt
,attendance_log.txt
.