0% found this document useful (0 votes)
19 views

Programming Cc4001

The document describes a Java Swing graphical user interface for a staff recruitment system. It includes: - Methods to get user input from text fields like vacancy number, staff name, salary etc. and store them in variables. - Pseudocode for different user interactions: adding a full-time vacancy, adding a part-time vacancy, setting salary of a full-time staff member. - The pseudocode increments counters on button clicks, enables/disables relevant fields and calls functions based on the counter values. It aims to provide an understanding of creating interactive GUIs using Java Swing by implementing a recruitment system interface and handling different user events.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Programming Cc4001

The document describes a Java Swing graphical user interface for a staff recruitment system. It includes: - Methods to get user input from text fields like vacancy number, staff name, salary etc. and store them in variables. - Pseudocode for different user interactions: adding a full-time vacancy, adding a part-time vacancy, setting salary of a full-time staff member. - The pseudocode increments counters on button clicks, enables/disables relevant fields and calls functions based on the counter values. It aims to provide an understanding of creating interactive GUIs using Java Swing by implementing a recruitment system interface and handling different user events.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

CS4001- PROGRAMMING – 2022/23

RECRUITMENT SYSTEM

1
Table of Contents
Cover Sheet ...................................................................................................................................................................... 3
Introduction ..................................................................................................................................................................... 4
Method Description..........................................................................................................................................................6
Pseucode:........................................................................................................................................................................... 7
Conclusion....................................................................................................................................................................... 20

2
Cover Sheet :

21048721

Darius-Daniel-Sebastian curticapean
23/04/2023

3
Introduction :
Graphical User Interfaces (GUIs) are an integral part of modern software development. A well-designed GUI
can enhance user experience and make software applications more intuitive and user-friendly. This
coursework gives me an opportunity to put in practice what learned in the last few months to construct a GUI
using Java Swing.

The aim of this coursework is to provide an in-depth understanding of how to create interactive and visually
appealing interfaces using Java Swing. This is an opportunity to explore the various Swing library elements
such as buttons, text fields, menus, and dialogues and learn how to combine them to create a cohesive and
functional user interface.

Through this coursework, I will also delve into topics such as event handling, layout managers, and user
input validation. I will put into practice how to handle users’ actions and events, position and align
components on the screen, and ensure that user inputs are validated and processed correctly.

By the end of this coursework, I hope to get a solid understanding of the principles and best practices of GUI
design using Java Swing. They will be equipped with the skills necessary to create elegant and user-friendly
interfaces for a wide range of software applications for my future projects.

4
5
Method Description:

 The getVacancy() method is designed to retrieve user input from a text field that represents the
number of vacancies, and then store that value in the vacancy variable.

 The getJobType() method is designed to retrieve user input from a text field that represents the
type of job, and then store that value in the jobType variable.

 The getStaffName() method is designed to retrieve user input from a text field that represents the
name of the staff member, and then store that value in the staffName variable.

 The getQualification() method designed the user to retrieve user input from a text field that
represents the qualification of the staff member, and then store that value in the Qualification
variable.

 The getDesignation() method is designed to retrieve user input from a text field that represents the
designation of a staff member and then store that value in the designation variable.

 The getJobType() method is designed to retrieve user input from a text field that represents the
type of job, and then store that value in the jobType variable.

 The getAppointedBy() method is designed to retrieve user input from a text field that represents the
person who appointed the staff member, and then store that value in the appointed variable.

 The getVacancy() method is designed to retrieve user input from a text field that represents the
number of vacancies, and then store that value in the vacancy variable.

 The getJoin() method is designed to retrieve user input from this button and return the value
indicating if the staff member has joined or not.

 The getWeekFractionalHours() method is used to retrieve user input from a text field named
weekFractionalText that represents the number of fractional hours worked in a week.

 The getWeekFractionalHours() method is designed to retrieve the user input from a text field named
weekFractionalText that is used to input the number of fractional hours worked in a week.

 The getWorkingHours() method is likely designed to retrieve user input from a text field that
represents the number of working hours, and then store that value in the workingHours variable.

 The getShift() method is likely designed to retrieve user input from a text field that represents the
shift worked by the staff member, and then store that value in the shifts variable.

 The fulltimeStaffButton is clicked, an action listener is generated which increments a "click" counter
variable. The code then enables or disables multiple text fields based on the user's input.

 The partimeButton in a graphical user interface. When the button is clicked, an action listener is
generated that toggles the visibility of certain text fields and increments a counter.

 the salaryButton in a graphical user interface. When the button is clicked, it increments a “click2”
counter and enables/disables certain text fields.

6
 The workingshiftButton defines button's functionality, which waits for the user to click it. On clicking,
the code increments "click3", enables certain components, disables others, and retrieves job
information.

 The Terminate button code creates an ActionListener for the GUI element terminate button, which
handles the termination of an employee's employment. The code increments the "click4" counter
and enables/disables certain text fields based on user input.

 The getDisplay() method is likely used in a program with a graphical user interface (GUI) and is
designed to retrieve the user input from a text field that represents a display number and store that
value in a variable called displayNumber.

 The Display Button code is designed to display the details of a particular job opening or employee
appointment when the user enters a corresponding index number and clicks the Display Button in
the GUI.

Pseucode:

• Add a vacancy for a full-time staff member

// This code block increments the click counter for the full-time staff hire button by 1 and resets the other
counters

INCREMENT click BY 1
SET click1 to 0
SET click2 to 0
SET click3 to 0
SET click4 to 0

// This code block enables the relevant input fields for full-time staff hire and disables the irrelevant input
fields
ENABLE vacancyText
ENABLE jobTypeText
ENABLE staffNameText
ENABLE qualificationText
ENABLE designationText
ENABLE jobDateText
ENABLE AppointedText
ENABLE salaryText
ENABLE Joined
ENABLE weekFractionalText

DISABLE WorkingHoursText
DISABLE wegesText
DISABLE shiftsText

7
// This code block enables the buttons for full-time staff hire and disables the buttons for part-time staff hire
and termination

ENABLE salaryButton
ENABLE workingShiftsButton
ENABLE terminateButton

// This code block checks if the click counter for full-time staff hire reaches the threshold of 2 and calls the
fulltime() function if it does
IF click is greater than or EQUAL to 2, then CALL fulltime() function

• Add a vacancy for a part-time staff member

// Increment click1 counter and reset other counters


click1++

// Reset other click counters


click = 0
click2 = 0
click3 = 0
click4 = 0

// Enable relevant input fields


vacancyText.setEnabled(true)
jobTypeText.setEnabled(true)
staffNameText.setEnabled(true)
qualificationText.setEnabled(true)
designationText.setEnabled(true)
jobDateText.setEnabled(true)
AppointedText.setEnabled(true)
salaryText.setEnabled(true)
WorkingHoursText.setEnabled(true)
shiftsText.setEnabled(true)
wegesText.setEnabled(true)

// Disable irrelevant input fields


Joined.setEnabled(false)
weekFractionalText.setEnabled(false)

// Enable relevant buttons


salaryButton.setEnabled(true)
workingShiftsButton.setEnabled(true)
terminateButton.setEnabled(true)

// Check if click1 counter reaches a threshold of 2 or more


if (click1 >= 2) {
// Call partTime function
partTime()
}

• Set Salary full-time staff member

// When salaryButton is clicked salaryButton.addActionListener(new ActionListener() {


@Override
8
public void actionPerformed(ActionEvent e) {
// Increment click2 counter and reset other counters
// Enable relevant input fields

click2++;
click = 0;
click3 = 0;
click1 = 0;
click4 = 0;

vacancyText.setEnabled(true);
staffNameText.setEnabled(true);
salaryText.setEnabled(true);

// Disable irrelevant input fields


jobTypeText.setEnabled(false);
qualificationText.setEnabled(false);
designationText.setEnabled(false);
jobDateText.setEnabled(false);
AppointedText.setEnabled(false);
WorkingHoursText.setEnabled(false);
wegesText.setEnabled(false);
weefFractionalText.setEnabled(false);
shiftsText.setEnabled(false);

// If click2 counter reaches a threshold of 2 or more


if (click2 >= 2) {
// Get vacancy, staff name, and salary input values
int vacancy = getVacancy();
String name = getStaffName();
boolean found = false;
displayAreaTex.setText("");

// Iterate through staffHires ArrayList to find matching FullTimeStaffHire object


for (StaffHire staffHire : staffHires) {
// Check if staffHire is of type FullTimeStaffHire
if (staffHire instanceof FullTimeStaffHire fullTimeStaffHire) {
// Check if vacancy number and staff name matches
if (fullTimeStaffHire.getVacancyNumber() == vacancy &&
fullTimeStaffHire.getStaffName().equals(name)) {
// Set the salary and display FullTimeStaffHire details
fullTimeStaffHire.setSalary(getSalary());
displayAreaTex.append(fullTimeStaffHire.fullTimeDetails());
found = true;
break;
}
}
}

// If no matching FullTimeStaffHire object found, show error message


if (!found) {
JOptionPane.showMessageDialog(null, "The number and name does not match");
}
}
}

9
}
});

• Set Working shifts part-time staff member

// Add action listener to workingShiftsButton


workingShiftsButton.addActionListener(new ActionListener() {
// Override actionPerformed method
@Override
public void actionPerformed(ActionEvent e) {
// Increment click3 and reset other click variables
click3++;
click2 = 0;
click4 = 0;
click = 0;
click1 = 0;
// Enable vacancyText, staffNameText and shiftsText
vacancyText.setEnabled(true);
staffNameText.setEnabled(true);
shiftsText.setEnabled(true);
// Disable jobTypeText, qualificationText, designationText, jobDateText,
// AppointedText, WorkingHoursText, wegesText, weefFractionalText, and salaryText
jobTypeText.setEnabled(false);
qualificationText.setEnabled(false);
designationText.setEnabled(false);
jobDateText.setEnabled(false);
AppointedText.setEnabled(false);
WorkingHoursText.setEnabled(false);
wegesText.setEnabled(false);
weefFractionalText.setEnabled(false);
salaryText.setEnabled(false);
// Check if click3 is greater than or equal to 2
if (click3 >= 2) {
// Get vacancy and staff name
int vacancy = getVacancy();
String name = getStaffName();

10
boolean found = false;

displayAreaTex.setText("");
// Iterate through staffHires and find the PartTimeStaffHire object with
// the given vacancy number and staff name

for (StaffHire staffHire : staffHires) {


if (staffHire instanceof PartTimeStaffHire partTimeStaffHire) {
if (partTimeStaffHire.getVacancyNumber() == vacancy &&
partTimeStaffHire.getStaffName().equals(name)) {
// Set shifts for the PartTimeStaffHire object and append partTimeDetails to displayAreaTex
partTimeStaffHire.setShifts(getShift());
displayAreaTex.append(partTimeStaffHire.partTimeDetails());
found = true;
break;
}
}
}
// If no matching PartTimeStaffHire object is found, display an error message
if (!found) {
displayAreaTex.setText("");
JOptionPane.showMessageDialog(null, "The number and name does not match");
}
}
}
});

• Terminate a part-time staff member

//The following code searches for a FullTimeStaffHire object with the matching vacancy number in the staff-
Hires list.
for (StaffHire staffHire : staffHires) {
if (staffHire instanceof FullTimeStaffHire && staffHire.getVacancyNumber() == number)
{ FullTimeStaffHire fullTimeStaffHire = (FullTimeStaffHire) staffHire;

//The following code appends the termination string to the displayAreaText.


displayAreaText.append(fullTimeStaffHire.terminate());

11
//The following code removes the FullTimeStaffHire object from the staffHires list.
staffHires.remove(fullTimeStaffHire);

//The following code displays a success message.


JOptionPane.showMessageDialog(null, "Employee has been terminated.");

//Exit the loop as soon as a matching FullTimeStaffHire object is found.


break;

}
}

//The following code checks whether the staffHires list is empty or not, and updates the displayAreaText ac-
cordingly.
if (staffHires.isEmpty())
{ displayAreaText.setText("No staff hired yet.");

} else {
displayAreaText.setText("");
for (StaffHire staffHire : staffHires) {
displayAreaText.append(staffHire.display());
}
}
}
});

• Displaying a staff members in the arraylist

displayNumberButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
// Check if the display value is within the range of staffHires list
if(getDisplay() <= (staffHires.size() - 1))
{
// Loop through the staffHires list and find the staff hire at the given display value
for (int i = 0; i <= staffHires.size() - 1; i++)
{
// Check if the staff hire at the given index is a FullTimeStaffHire object
if (staffHires.get(getDisplay()) instanceof FullTimeStaffHire fullTimeStaffHire)
{
// Clear the display area text and append the staff details of the FullTimeStaffHire object
displayAreaTex.setText("");
displayAreaTex.append(fullTimeStaffHire.staffDetails());
break;
}
// Check if the staff hire at the given index is a PartTimeStaffHire object
else if (staffHires.get(getDisplay()) instanceof PartTimeStaffHire partTimeStaffHire)
{
// Clear the display area text and append the staff details of the PartTimeStaffHire
object displayAreaTex.setText("");
displayAreaTex.append(partTimeStaffHire.partTimeDetails());

12
break;
}
}
}
// If the display value is out of range, show an error message
else
{

}
});

13
14
15
Conclusion:
In conclusion of the challenging Java coursework, it is evident that the level of complexity in the project was beyond
what was expected. Despite the difficulty in grasping the entire concept, the project presented a great learning
opportunity for me as a future computer network engineer.
The amount of time spent on the coursework besides other commitments was extensive, but the effort put into it
allowed me to explore new skills in coding.
The coursework proved to be a valuable experience, allowing me to broaden my understanding of Java programming,
and enhance my problem-solving skills.
While the challenge was daunting, it provided an excellent opportunity for personal growth and development. Overall,
despite the difficulties encountered, the coursework provided an invaluable learning experience which makes me feel
more confident in my programming abilities as the conclusion of another coursework result.

16

You might also like