ASSIGNMENT 3 STATIC METHODS AND MEMBER VARIABLES
Department of Computer Science, University of the People
CS 1102-01 Programming 1-AY2026-T
Mopelola Akinyemi
September 17th,2025
Explanatory Document (MS Word):
Introduction
This paper describes the design and development of a Student Record Management System
(SRMS), done using Java. The SRMS allows the administrator to manage student records with
ease by adding, modifying, or viewing pdf student records. Although object-oriented design
principles suggest alternatives to data storage, the SRMS adheres to assignment constraints by
using static variables.
1. Software Requirements
Java Development Kit (JDK): Version 8 or higher.
Integrated Development Environment (IDE) (Recommended): IntelliJ IDEA, Eclipse or VS
Code.
Command-Line Interface (CLI): Required to compile and run the application..
2. Design and Implementation
• Student Class:
* A nested static class, Student, encapsulates student attributes:
* name (String): Student’s name.
* id (int): Unique student ID.
* age (int): Student’s age.
* grade (String): Student’s grade level.
* A toString() method provides a formatted representation of student data.
• Static Variables:
* studentList (List\<Student>): A static ArrayList stores Student objects. An ArrayList was
selected to enable dynamic resizing of the student list.
* totalStudents (int): A static integer to track the total count of students, incremented upon
adding new students, though the real number of students is derived from [Link]().
• Methods:
addStudent(Scanner scanner):
* Prompts the administrator for student details.
* Creates a new Student object.
* Adds the new student to studentList.
* Increments totalStudents.
* Includes input validation to prevent duplicate student Ids.
* updateStudent(Scanner scanner):
* Prompts for the ID of the student to update.
* Retrieves the Student object using findStudentById().
* Prompts for new details and updates the Student object if found.
* viewStudent(Scanner scanner):
* Prompts for the ID of the student to view.
* Retrieves the Student object using findStudentById().
* Displays student information via toString() if found.
* findStudentById(int id):
* Iterates through studentList to locate a student with a matching ID.
* Returns the Student object if found; otherwise, returns null.
* getValidIntInput(Scanner scanner, String message):
* Prompts for integer input and validates to ensure proper integer format.
* Catches InputMismatchException and re-prompts until valid input is received.
logError(String message, Exception e):
* Logs an error message with the given message and exception using Java’s built-in
logging framework.
* main(String[] args):
* Displays the main menu and manages processing user interaction.
* Uses a Scanner to obtain user input.
* switchstatement calls the designated function based on user choice.
* Contains robust exception handling, outputting errors to the console.
3. Error Handling:
* Catches InputMismatchException for invalid menu options and for inputs that are not integers
(Deitel & Deitel, 2018).
* findStudentById() returns null if unable to find an ID.
How to Compile and Run:
1. Save: Save the file as [Link].
2. Compile: Open the command prompt or terminal, navigate to the directory where the file is
saved and compile with:
Javac [Link]
3. Run: Run the program:
Java StudentRecordManagement
Administrator Interface Interaction
• Adding a Student:
1. Select option 1.
2. Enter the requested information at the prompts.
• Updating a Student:
1. Select option 2.
2. Enter the student ID for the student to be updated.
3. Enter the new information as prompted.
• Viewing a Student:
1. Select option 3.
2. Enter the student ID for the student to be viewed.
• Exiting:
1. Select option 4.
4. Architectural Considerations
The current implementation allocates all application state to static memory. This meets the direct
assignment requirements, but it also strays from standard object-oriented designs (Gamma,
Helm, Johnson, & Vlissides, 1994). If built as a real application, a plan for a more modular
design (such as a separate "StudentManagement" class to do all data accessing) would be
expected. However, the use of a more modular design has been explicitly avoided for the purpose
of following the assignment's request of a ‘classless’ design so that all the important state and
methods for the class fall within the scope of the main class.
5. Possible Extensions
Persistence: Providing file-based access (such as CSV, JSON) for data persistence (Jackson,
2012).
More Validation: Add validation on input (such as regex for names, age, etc.).
Search: Ability to search for a student.
GUI: Build a graphical user interface (GUI) with Swing or JavaFX.
Logging Framework: Create a better logging framework.
Words count: 739
References
Deitel, P. J., & Deitel, H. M. (2018). Java How to Program (11th ed.). Pearson Education.
Gamma, E., Helm, R., Johnson, R., & Vlissides, J. (1994). Design Patterns: Elements of
Reusable Object-Oriented Software. Addison-Wesley.
Jackson, M. (2012). JSON Processing in Java. O’Reilly Media.
Sierra, K., & Bates, B. (2005). Head First Java. O’Reilly Media.