Uploaded by Sagit

PROG191 Java OOP

advertisement
ASSIGNMENT 1 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Submission date
04/05/2022
Re-submission Date
Date Received 1st submission
Date Received 2nd submission
Student Name
Võ Minh Quốc
Student ID
GCD201870
Class
GCD0904
Assessor name
Phạm Thanh Sơn
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Student’s signature
Grading grid
Grade (0-10)
1
Quoc
❒Summative Feedback:
Grade:
IV Signature:
❒Resubmission Feedback:
Assessor Signature:
Date:
2
Table of Contents
I.
INTRODUCTION:.................................................................................................................................................................................................................................. 4
II.
USER REQUIREMENTS: ...................................................................................................................................................................................................................... 4
III.
UI DESIGN ......................................................................................................................................................................................................................................... 5
IV.
IMPLEMENTATION......................................................................................................................................................................................................................... 8
1.
2.
3.
4.
LINK GITHUB: ................................................................................................................................................................................................................................................................. 8
CLASSES: ......................................................................................................................................................................................................................................................................... 9
PROGRAM STRUCTURE: ................................................................................................................................................................................................................................................12
IMPORTANT ALGORITHMS: ..........................................................................................................................................................................................................................................15
A. Adding student: .................................................................................................................................................................................................................................................................................. 15
B. Delete student: .................................................................................................................................................................................................................................................................................... 17
5. ERRORS HANDLED:.......................................................................................................................................................................................................................................................19
V.
TEST .................................................................................................................................................................................................................................................... 23
1.
2.
3.
VI.
TEST PLAN ....................................................................................................................................................................................................................................................................23
TEST LOG ......................................................................................................................................................................................................................................................................27
TEST RESULT: ...............................................................................................................................................................................................................................................................34
RESULT........................................................................................................................................................................................................................................... 56
1.
2.
3.
ADDING FUNCTION: ......................................................................................................................................................................................................................................................56
UPDATING FUNCTION: .................................................................................................................................................................................................................................................62
DELETING FUNCTION: ..................................................................................................................................................................................................................................................68
VII.
CONCLUSION:................................................................................................................................................................................................................................ 78
1.
2.
WHAT I LEANT: ............................................................................................................................................................................................................................................................78
WHAT I NEED TO IMPROVE..........................................................................................................................................................................................................................................78
3
I.
Introduction:
An IETLS center have many difficulties in managing students, but they are choosing storing information of students in the papers, as a
result, a small amount of student data has been lost because of the papers’ length of life, or when they want to transfer the data to
another storage place, they need to copy it by handwriting, or even when searching the information of student, this make time-wasted.
Therefore, they hired me to design the student management application in order to support them in managing their students’
information. The application must have many important criteria, such as having the graphical user interface, reading, and writing
student data from file, having ability to work with the collection of data (searching for item). In addition, having application tested
before deploying it to ensure the crash must not happen at end user side.
II.
User requirements:
After listening their requirements, I noted and analyzed their requirements. I concluded and wrote them down clearly. They want the
software:
-
-
Can manage student:
 ID: this is unique,
 Name
 Gender
 Birthday
 Email
 Phone number
Have four main functions:
 Create: To save information of student.
 Read: To display all or found students.
 Update: To update information of student.
 Delete: To delete information of student.
4
-
And have more sub-functions, such as:
 Sorting ascending, descending information of students by their ID
 Find student by id and/or name
III. UI Design
-
Wireframing is a way to design a website service at the structural level. A wireframe is a layout of a web page that
demonstrates what interface elements will exist on key pages. It is a critical part of the interaction design process. Because the
aim of a wireframe is to provide a visual understanding of a page early in a project to get stakeholder and project team
approval before the creative phase gets underway, I decided to place it in this report to support my work become easy, and also
customer can understand my application which I designed for them. This is a wireframe of student management software:
5
-
These are the fields for user to type and choose students’ information, including:
 Text fields with rectangle shape which is the place to type student information, such as ID, Name, Birthday, Email,
Phone number.
 Two radio buttons for choosing student gender.
6
-
These are the place for user to choose which function they want to implement through 3 radio buttons, ‘Add Function’,
‘Update Function’, and ‘Delete Function’; and corresponding to those three radio buttons if they are turned on, are three
buttons for implementation of saving, updating, delete student information.
-
This is the place for user to find the student information by searching ID and/or Name of them.
7
-
This is the two radio buttons to choosing for sorting ascending and descending students’ information by their ID
-
This is the table for display the information of students for all or found students.
IV. Implementation
1. Link github:
https://github.com/Sagit612/ProjectJava
8
2. Classes:
There are 4 classes in my program, including:

‘StudentController’ class: contains CRUD functions, check information functions, read/write file functions, sorting student information
functions. Those functions have the mission to handle the data and then pass it to the class ‘MainFrame’ which is the view.
9

‘Student’ class: contains field (id, name, gender, birthday, email, phone number), contructors, functions getter and setter.
10

‘MainFrame’ class: contain button, table,…, return student information, getting from ‘StudentController’ class, to table functions. This
class also handle the button events.

‘App’ is the class main which help running the program.
11
3. Program structure:
12
13
This is structure of my program, including 4 class, ‘Student’ class, ‘StudentController’ class, ‘MainFrame’ class. Whenever the program starts, the
view appears and the ‘ReadDataFromFile’ function is called with its function passing the data from file to list and the data will be passed into the
‘ArrayList’, then the data from the ‘Database’ file are passed into the ‘ReadFile’ function. The view contain:




Text field of id, name , birthday, email, phone number, and search id and name: to get text for handling.
Radio button of choosing genders, add/delete/update functions, and sorting function.
Button: Save, Delete, Update, Search
Table to display the information of students
14
Whenever user add interact with view, the view will receive user actions such as adding, deleting, updating, the view has the mission to receive
data through text field such as id, name text field, the data will be passed into view, followed by controller, and given to a certain function to
handle, then the handled data will be passed into the ‘ArrayList’ and continuedly transferred to ‘WriteToFile’ function in order to write or override
them into the ‘Database’ file. The ‘Database’ file, then, will be read by ‘ReadFile’ function, and after that data corresponding with user need will
be returned to the view.
4. Important algorithms:
A. Adding student:
This is a flowchart of adding new student to ‘database.txt’ file
15
-
Explanation:
 ‘studentInformation’ represents for id, name, gender, birthday, email, and phone number of student
 ‘studentInformation.isEmpty()’ is to check if user entered student’s information.
 ‘CheckStudentInformation(studentInformation)’ is a function from ‘StudentController’ class to check if student information is
duplicated.
16

‘CheckStudentInformationValid(studentInformation)’ is a function from ‘StudentController’ class to check if student
information is valid or not.
When user want to add new student, they need to enter information of that student, if information is null the program will alert and force
user to enter information. Then the program receives that information to check it first if it is unique (except for name and birthday) or
valid, if not, program will force user to enter again until that information is unique and valid, after everything is correct, the program will
process it by add it to array list and write that array list to file.
B. Delete student:
This is the flowchart of deleting student by id
17
-
Explanation:
 ‘id.isEmpty()’ is to check if user entered id.
 ‘_students.size()’ is the size of the array list.
18
-
 ‘_student.get(i).getId()’ is to get the student ‘i’ with their information
 ‘_student.get(i).getId().equal(id)’ is to compare whether the student id is equal entered id or not.
When user want to delete student, they need to enter the id of that student, then the program receives that id to check it first if it is null or
not if yes, program will force user to enter, after everything is correct, the program will process it by finding student with that entered id
and delete it from array list, after that the array list will be written into file.
5. Errors handled:
Everything happened normally when I add student into table, it was successful.
When I try to enter the string into the table, it still accepted the data and pass it into the table.
19
20
Then I create the function ‘checkbirthday’ to check the birthday is valid or not, but the when I tried to add birthday with the remaining student
information, it appeared the error.
21
Then I handled that error by catching that DateTimeParseException.
22
And if the birthday format that user enter into table is wrong, the catch will not handle that and the function return false, and then handling it at the
‘if… else’ statement
V.
Test
1. Test plan
Button
Test case ID
Plan
Start date
1
Check ‘Male’ radio
02/05/2022
button is still selected
or not when switching
the selection between
2 buttons, ‘Male’
23
End date
02/05/2022
Estimate Time
(Hrs/Day)
2 hours
radio button and
‘Female’ radio button
2
3
4
5
Check ‘Female’ radio
button is still selected
or not when switching
the selection between
2 buttons, ‘Male’
radio button and
‘Female’ radio button
Check ‘Add Function’
radio button is still
selected or not when
switching the
selection between 2
buttons, ‘Add
Function’ radio button
and ‘Delete Function’
radio button and
‘Update Function’
radio button
Check ‘Delete
Function’ radio button
is still selected or not
when switching the
selection between 2
buttons, ‘Add
Function’ radio button
and ‘Delete Function’
radio button and
‘Update Function’
radio button
Check ‘Update
Function’ radio button
is still selected or not
when switching the
selection between 2
24
6
7
Function
8
9
10
11
12
buttons, ‘Add
Function’ radio button
and ‘Delete Function’
radio button and
‘Update Function’
radio button
Check ‘Sorting Asc’
radio button is still
selected or not when
switching the
selection between 2
buttons, ‘Sorting Asc’
radio button and
‘Sorting Desc’ radio
button
Check ‘Sorting Desc’
radio button is still
selected or not when
switching the
selection between 2
buttons, ‘Sorting Asc’
radio button and
‘Sorting Desc’ radio
button
Add student with valid
information
Add student with
invalid information
Delete student
Delete none student
Update student’s
information by the
25
13
14
15
16
17
18
19
20
new valid student
information
Update student’s
information with
information
overlapping with
another information in
the database
Update student with
the new invalid
information
Sort student
information ascending
by id
Sort student
information
descending by id
Search student’s id
which is available in
‘Database’ file
Search student’s name
which is available in
‘Database’ file
Search student’s id
and name which is
available in
‘Database’ file
Search student’s id
which is not available
in ‘Database’ file
Search student’s name
which is not available
in ‘Database’ file
Search student’s name
and id which is not
available in
‘Database’ file
26
21
Table
22
Search student’s
information with
invalid information
Check program alerts
or not when clicking
any row on table
without turning on
‘Delete Function’ and
‘Update Function’
function
2. Test log
Button
Test case ID
1
Check
‘Male’ radio
button is still
selected or
not when
switching the
selection
between 2
buttons,
‘Male’ radio
button and
‘Female’
radio button
2
Check
‘Female’
radio button
is still
selected or
not when
Procedure
Expected result
Click ‘Male’ radio buton ‘Male’ radio button is
Click ‘Female’ radio
still selected
button
Click ‘Male’ radio
button
Result
PASSED
Click ‘Female’ radio
button
Click ‘Male’ radio
button
Click ‘Female’ radio
button
PASSED
‘Female’ radio button is
still selected
27
3
4
switching the
selection
between 2
buttons,
‘Male’ radio
button and
‘Female’
radio button
Check ‘Add
Function’
radio button
is still
selected or
not when
switching the
selection
among 3
buttons,
‘Add
Function’
radio button,
‘Delete
Function’
radio button
and ‘Update
Function’
radio button
Check
‘Delete
Function’
radio button
is still
selected or
not when
switching the
selection
among 3
Click ‘Add Function’
radio button.
‘Add Function’ radio
button is still selected
PASSED
Click ‘Delete Function’
radio button.
Click ‘Delete’ button
‘Delete Function’ radio
button is still selected
PASSED
28
5
6
buttons,
‘Add
Function’
radio button,
‘Delete
Function’
radio button
and ‘Update
Function’
radio button
Check
‘Update
Function’
radio button
is still
selected or
not when
switching the
selection
among
buttons,
‘Add
Function’
radio button,
‘Delete
Function’
radio button
and ‘Update
Function’
radio button
Check
‘Sorting Asc’
radio button
is still
selected or
not when
switching the
Click ‘Update Function’
radio button.
Click ‘Update’ button
‘Update Function’ radio
button is still selected
PASSED
Click ‘Sorting Asc’
radio button
Click ‘Sorting Desc’
radio button
Click ‘Sorting Asc’
radio button
‘Sorting Asc’ radio
button is still selected
PASSED
29
7
Function 8
selection
between 2
buttons,
‘Sorting Asc’
radio button
and ‘Sorting
Desc’ radio
button
Check
‘Sorting
Desc’ radio
button is still
selected or
not when
switching the
selection
between 2
buttons,
‘Sorting Asc’
radio button
and ‘Sorting
Desc’ radio
button
Add student
with valid
information
Click ‘Sorting Desc’
radio button
Click ‘Sorting Asc’
radio button
Click ‘Sorting Desc’
radio button
‘Sorting Desc’ radio
button is still selected
PASSED
Click ‘Add Function’
radio button.
Type valid information
Click ‘Save’ button
Student will be added on
‘Database’ file and table
And the program will
announce ‘ADD
SUCCESSFULLY’
The program will give
the alert until user
typing the valid
information
PASSED
Student will be deleted
from table and
‘Database’ file
PASSED
9
Add student
with invalid
information
Click ‘Add Function’
radio button
Type valid information
for each text field
10
Delete
student
Click ‘Delete Function’
radio button
30
PASSED
Choose student need to
be deleted by clicking
on the row containing it
on the table
Click ‘Delete’ button
Click ‘Delete Function’
radio button
Click ‘Delete’ button
11
Delete none
student
12
Update
student’s
information
by the new
valid student
information
Click ‘Update Function’
radio button
Choose student needing
to be updated by
clicking on the row
containing it on the table
Their information will
be filled on the text field
automatically
Change that information
by the new valid
information
Click ‘Update Function’
button
13
Update
student’s
information
with
information
overlapping
with another
information
in the
database
Click ‘Update Function’
radio button
Choose student needing
to be updated by
clicking on the row
containing it on the table
Their information will
be filled on the text field
automatically
Change that information
by the overlapping
information on the table
And the program will
announce ‘ADD
SUCCESSFULLY’
The program will give
the alert until user
choose the row
containing student
information on the table
Student will be updated
their information on
‘Database’ file and table
And the program will
announce ‘UPDATE
SUCCESSFULLY’
PASSED
The program will give
the alert until user types
the valid information
that is not overlapping
with another id on the
table and ‘Database’ file
FAILED
31
PASSED
Click ‘Update Function’
button
14
Update
student with
the new
invalid
information
Click ‘Update Function’
radio button
Choose student needing
to be updated by
clicking on the row
containing it on the table
Their information will
be filled on the text field
automatically
Change that information
by the new invalid
information
Click ‘Update Function’
button
The program will give
the alert until user type
the valid information.
PASSED
15
Sort student
information
ascending by
id
Sort student
information
descending
by id
Search
student’s id
which is
available in
‘Database’
file
Search
student’s
name which
is available
Click ‘Sort Asc’ radio
button
Student information on
the table will be sorted
ascending by id
PASSED
Click ‘Sort Desc’ radio
button
Student information on
the table will be sorted
descending by id
PASSED
Type student ID which
is available in
‘Database’ file to search
Click ‘Search’ button
Only student has that ID
will be appeared on the
table
PASSED
Type student name
which is available in
‘Database’ file to search
Click ‘Search’ button
Student has that string
will be appeared on the
table
PASSED
16
17
18
32
19
20
21
22
23
Table
24
in ‘Database’
file
Search
student’s id
and name
which is
available in
‘Database’
file
Search
student’s id
which is not
available in
‘Database’
file
Search
student’s
name which
is not
available in
‘Database’
file
Search
student’s
name and id
which is not
available in
‘Database’
file
Search
student’s
information
with invalid
information
Check
program
alerts or not
Type student ID with
their name which is
available in ‘Database’
file to search
Click ‘Search’ button
Only student has that ID
and name will be
appeared on the table
PASSED
Type student Id which is
not available in
‘Database’ file to search
Click ‘Search’ button
There will be nothing on
the table
PASSED
Type student name
which is not available in
‘Database’ file to search
Click ‘Search’ button
There will be nothing on
the table
PASSED
Type student id with
their name in both
corresponding text fields
which is not available in
‘Database’ file to search
Click ‘Search’ button
There will be nothing on
the table
PASSED
Type any invalid
information in both text
fields
Click ‘Search’ button
There will be nothing on
the table
PASSED
Click to the table
without turning on
‘Delete Function’ or
The program will alert
until user choosing the
function
PASSED
33
when
clicking any
row on table
without
turning on
‘Delete
Function’
and ‘Update
Function’
function
‘Update Function’ radio
button
3. Test result:
Test case 1: Check ‘Male’ radio button is still selected or not when switching the selection between 2 buttons, ‘Male’ radio button and ‘Female’
radio button.
 ‘Male’ radio button is still selected
Test case 2: Check ‘Female’ radio button is still selected or not when switching the selection between 2 buttons, ‘Male’ radio button and ‘Female’
radio button
34
 ‘Female’ radio button is still selected
Test case 3: Check ‘Add Function’ radio button is still selected or not when switching the selection among 3 buttons, ‘Add Function’ radio button,
‘Delete Function’ radio button and ‘Update Function’ radio button
 ‘Add Function’ radio button is still selected
Test case 4: Check ‘Delete Function’ radio button is still selected or not when switching the selection among 3 buttons, ‘Add Function’ radio
button, ‘Delete Function’ radio button and ‘Update Function’ radio button
35
 ‘Delete Function’ radio button is still selected
Test case 5: Check ‘Update Function’ radio button is still selected or not when switching the selection among buttons, ‘Add Function’ radio
button, ‘Delete Function’ radio button and ‘Update Function’ radio button
 ‘Update Function’ radio button is still selected
Test case 6: Check ‘Sorting Asc’ radio button is still selected or not when switching the selection between 2 buttons, ‘Sorting Asc’ radio button
and ‘Sorting Desc’ radio button
36
 ‘Sorting Asc’ radio button is still selected
Test case 7: Check ‘Sorting Desc’ radio button is still selected or not when switching the selection between 2 buttons, ‘Sorting Asc’ radio button
and ‘Sorting Desc’ radio button
 ‘Sorting Desc’ radio button is still selected
Test case 8: Add student with valid information
37
 Added successfully
Test case 9: Add student with invalid information
38
39
 The alert appeared until the valid information are typed.
Test case 10: Delete student
40
 Deleted successfully
Test case 11: Delete none student
41
 The alert appeared to remind user of choosing student from table
Test case 12: Update student’s information by the new valid student information
42
 Updated successfully
43
Test case 13: Update student’s information with information overlapping with another information in the database
44
 Failed, because the updating still implemented successfully without checking information overlapping or not.
Test case 14: Update student with the new invalid information
 The alert appeared until the valid information are typed.
45
Test case 15: Sort student information ascending by id.
 Student information were sorted by id
46
Test case 16: Sort student information descending by id
 Student information were sorted by id
Test case 17: Search student’s id which is available in ‘Database’ file
47
 Information of student with corresponding id appeared
Test case 18: Search student’s name which is available in ‘Database’ file
48
 Information of student containing corresponding name string appeared
Test case 19: Search student’s id and name which is available in ‘Database’ file
49
 Information of student with corresponding id and name appeared
Test case 20: Search student’s id which is not available in ‘Database’ file
50
 Because there is no student with ID = 15 in database, so the program returned the empty table.
Test case 21: Search student’s name which is not available in ‘Database’ file
51
 Because there is no student with Name = Khang in database, so the program returned the empty table.
Test case 22: Search student’s name and id which is not available in ‘Database’ file
52
 Because there is no student with ID = 15 and Name = Khang in database, so the program returned the empty table.
Test case 23: Search student’s information with invalid information
53
 The program returned the empty table.
Test case 24: Check program alerts or not when clicking any row on table without turning on ‘Delete Function’ and ‘Update Function’ function
54
55
 The alert appears until user choosing function.
VI. Result
1. Adding function:
-
When running application:
56
-
Turning on the ‘Add Function”:
 Id text field will be opened.
 Name text field will be opened
 Gender radio buttons will be opened:
 Birthday text field will be opened.
57


Email text field will be opened.
Phone number text field will be opened.
58
-
Then I typed student information into those text field and chose their gender
59
-
After that, I clicked save and the panel would appear and announce that I added student information successfully
60
-
And this is a result of adding function
61
2. Updating function:
-
I used the result of adding function to continue the updating function.
-
When turning on the updating function:
62





Name text field will be opened
Gender radio buttons will be opened:
Birthday text field will be opened.
Email text field will be opened.
Phone number text field will be opened.
63
-
Then I chose which information would be updated by clicking on it, the student information appeared on the text field, except for Id would
not be updated.
64
-
After that I changed the student information, clicked update button, and the panel would appear and announce that I updated student
information successfully
65
66
-
This is the result of updating student information:
67
3. Deleting function:
-
I used the result of updating function information continue the deleting function.
68
-
Then I chose which information would be deleted by clicking on it, the student information appeared on the text field without changing it.
69
-
After that, I clicked delete button, and the panel would appear and announce that I deleted student information successfully
70
71
72
73
74
75
76
77
VII. Conclusion:
1. What I leant:
After implementing this project, I
-
Learnt how to apply the MVC model into this project to keep the program maintained and scaled easily.
Learnt how to handle the event happening through clicking buttons and make it more logical in order to avoid many errors.
Acknowledged that using test plan, test case, test log is indispensable, it helps me find the errors and handle it to avoid the crashing
happening when running the program.
Learnt how to read/write data from file in order to save the data, and load data whenever user runs the program.
Learn how to validate input to avoid user enter the wrong information by mistakes.
2. What I need to improve
-
In terms of the GUI which is interface of program, I found that my application was not well-designed, user-friendly, and it also has some
illogical flow of actions.
In terms of the program, I found that my program has some errors that I cannot handle, although they do not make my program crashed
when running, they are validated, and my test covered them as many as possible.
So, in the future, I will learn and invest myself more into it for improve my future program.
78
Download