New Lab 9
New Lab 9
This involves modeling a simple case of management of an academic department. The Student and
Department classes encapsulate data and behavior related to students and their management, while the
MainProgram class serves as the entry point for the simulation.
Exercise 1
Model a student as a class with the following attributes: Name (String); Age (int), and Level (String). Provide
getters for each attribute. Add a displayDetails method to display student details.
Exercise 2
Model a university department as a class with the following attributes: Student Array (Student[]); and
Current department size (int); Provide a constructor that takes an array of students as a parameter and
initializes the department size. Add the following methods: showStudentDetails to display details of all
students in the department; addStudent to add a new student to the department; and showStudentNames
to display only the names of students in the department.
Exercise 3
Create a main program that simulates the use of previous classes. Create a university department, for
example, the computer science department, with an initial array of students. Use the Department class
methods to display student details, add a new student, and then redisplay the student details and names
after adding. Display the result of each operation.
Exercise 4
Add a method generateEmailAddress ( ) that generates an email address based on the student's name and
age. Note that this method must be declared with the private access modifier, which means that it can only
be called from other methods inside the same class (Student in this case). The generateEmailAddress ( )
method is then called from the public displayDetails () method. You can customize the private method logic
to your specific needs to generate an email address in a way that makes sense for your application.
Exercise 5
Create the following packages:
• com.mypackage.department for the Department class;
• com.mypackage for Student and Main Program classes
Make necessary changes to the academic department management program to keep it functioning.