Download PROG191_Java Programming_Assignment and more Assignments Java Programming in PDF only on Docsity!
ASSIGNMENT 1 FRONT SHEET
Qualification BTEC Level 5 HND Diploma in Computing
Unit number and title
Submission date Date Received 1st submission
Re-submission Date Date Received 2nd submission
Student Name Mai Tran Tuan Anh Student ID GCD
Class GCD0904 Assessor name Pham Thanh Son
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 Tuan Anh
Grading grid
Grade (0-10)
❒ Summative Feedback: ❒ Resubmission Feedback:
Grade: Assessor Signature: Date:
Contents
- I. BUSINESS PROBLEM
- Scenario..................................................................................................................................................................................................................
- User requirements
- UI design.................................................................................................................................................................................................................
- II. IMPLEMENTATION
- Programming language and IDE
- Program structure
- Model
- View
- Controller
- A. LoginController
- B. MenuController
- C. IntructionController
- Main
- III. HANDLE EXCEPTION
- IV. TEST PLAN
- V. EXECUTING PROGRAM
- Figure 1: Login screen
- Figure 2: Main screen.....................................................................................................................................................................................................
- Figure 3: Instruction screen
- Figure 4: JavaFX............................................................................................................................................................................................................
- Figure 5: Scene builder user interface
- Figure 6: InteliJ user interface......................................................................................................................................................................................
- Figure 7: Application flowchart
- Figure 8: Book model (1)
- Figure 9: Book model (2)
- Figure 10: Creating fxml file using scene builder
- Figure 11: Inside a fxml file (Login screen)...................................................................................................................................................................
- Figure 12: Fxml files in the project
- Figure 13: Login Controller...........................................................................................................................................................................................
- Figure 14: File data.txt
- Figure 15: Function read data from file
- Figure 16: Function initialize (1)...................................................................................................................................................................................
- Figure 18: Edit function (1) Figure 17: Function initialize (2)....................................................................................................................................... Error! Bookmark not defined.
- Figure 19: Edit function (2)
- Figure 20: Add book function
- Figure 21: Delete function
- Figure 22: Instruction Controller..................................................................................................................................................................................
- Figure 23: Main
- Figure 24: Example of handling an exception
- Figure 25: Login screen
- Figure 26: Main screen.................................................................................................................................................................................................
- Figure 27: Instruction screen
table to display all the book’s information as well as all the action required from the manger. Last thing is the instruction
screen, where new user can have the guide of how to use the app effectively.
Figure 1 : Login screen
Figure 2 : Main screen
- Oracle's JavaFX is a software development platform for creating desktop and rich internet applications (RIAs) that may be
viewed on a range of devices. JavaFX Script and JavaFX Mobile are two components of the platform, which was created by Sun
Microsystems.
- The scripting language is designed to make it easy to utilize the Java Swing user interface toolkit to construct sophisticated
user interfaces that run on any platform that supports the Java standard edition. JavaFX allows the creation of graphical user
interfaces (GUIs) in a declarative language format that defines interface components from Java's Swing interface toolkit, as
well as a variety of display effects such as animation, vector graphics, audio tracks, and video, all of which run in a Java virtual
machine (JVM)
Figure 4 : JavaFX
- Scene Builder is a tool that allows you to drag and drop JavaFX UI components and then tell your JavaFX program to display
the user interface using the fxml file(s).
Figure 5 : Scene builder user interface
2. Program structure
- This is the flowchart of the application. At first the user will have to enter correctly their given account, including username
and password. After successfully login into the system, a new screen will appear with the table containing all the book’s
information. At this screen, the manager can choose actions to perform to these data, including read, create, edit and delete.
There’s also instruction for new user
Figure 7 : Application flowchart
3. Model
- With this application, I decided to work with MVC patterns, including a Model, View and Controller. First, I created a model –
a book class which contain all the properties of a book, including id, name, genre, author and quantity. I set private access
modifier in order to secure the data. I also declare function ToString, which return information of the book
Figure 8 : Book model (1) Figure 9 : Book model ( 2 )
Figure 11 : Inside a fxml file (Login screen)
- There are 3 files fxml in total. Remember that if developer want to use any resource from the Internet such as picture or
video, they would have to save it with the fxml file in order to appear them successfully
Figure 12 : Fxml files in the project
B. MenuController
- This is the Controller that mostly handle the flow of the system. First, I created a file that contain all the library book’s
information and put it in a file called data.txt
Figure 14 : File data.txt
- First, I declare an observableList, which will be the array that contain all the book information. Then I declare a function to
read all the data from this file and load it into a list using FileReader and BufferedReader. As you can see inside the data file,
each component of a book is separate with a “;”. I do this so that when I read the data from this file, I can separate each
component by splitting the “;” symbol and then add into the list. All of this will be put inside a try catch. This will prevent the
system from crashing when there is an error occurs during the executing process.
Figure 15 : Function read data from file