1. Trang chủ
  2. » Luận Văn - Báo Cáo

Assignment Java Programming (PROG191) Greenwich 2022

24 29 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 24
Dung lượng 1,36 MB

Nội dung

Assignment Java Programming (PROG191) 2022 Greenwich chuẩn Pass. To get Pass (5 – 6.5 points) - Student can design and implement GUI for the application solve a specific problem - Student knows how to load and save data from file. - Student knows how to handle errors by using exceptions - Student knows how to write test plan, execute test cases and log results. 2 Requirement List of requirements from the business problem. 3 UI design List of wiredframes 4 Implementation Explain program structure Explain classes Explain important algorithms Explain how to handle errors 5 Test Test plan, log, result 6 Result Screenshots of running program

ASSIGNMENT FRONT SHEET Qualification BTEC Level HND Diploma in Computing Unit number and title Submission date 01/05/2022 Re-submission Date Date Received 1st submission Date Received 2nd submission Student Name Nguyen Manh Tung Student ID GCH200064 Class GCH0907 Assessor name Dinh Duc Manh 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.1 Tung ❒ Summative Feedback: ❒ Resubmission Feedback: 2.1 Grade: IV Signature: Assessor Signature: Date: Contents I Introduction II Requirement III UI design VI Implementation Program structure Explain classes Explain important algorithms 10 V Testing 17 VI Result 18 VII Conclusion 23 Figure 1: Login interface Figure 2: Sign Up interface Figure 3: Home page interface Figure 4: Flow of system Figure 5: Classes Figure 6: LoginModel class Figure 7: MainModel class Figure 8: Login function (part 1) 10 Figure 9: Login function (part 2) 10 Figure 10: Signup function 11 Figure 11: setAccount function 11 Figure 12: wirteDataToFile function 12 Figure 13: Add function 12 Figure 14: showAccessory function 13 Figure 15: updateAccessory function 13 Figure 16: Edit function 13 Figure 17: Delete function 14 Figure 18: Delete all function 14 Figure 19: Sort function 15 Figure 20: Search function 15 Figure 21: LoadData function 15 Figure 22: WriteData Function 16 Figure 23: Error of if/else (part 1) 17 Figure 24: Error of if/else (part 2) 17 Figure 25: Error of Exception 17 Figure 26: Signup successful 19 Figure 27: Login Successful 19 Figure 28: Home page 20 Figure 29: Insert successful 20 Figure 30: Update function 21 Figure 31: Confirm of delete 21 Figure 32: Delete successful 22 Figure 33: Sort by ID from z to a 22 Figure 34: Search key "a" 23 I Introduction In this assignment, the problem is to develop an application to solve a business problem of auto accessories management The problem requires a graphical user interface with features that require reading/writing data from text files for login and signup functionality, working with data sets (like search) The application must handle errors so that it does not fail on the end-user side The application also needs to be fully tested before the production phase Attached is a technical report, it is necessary to write a technical report on the development of the application The content of the report includes design, implementation and testing II Requirement The user is the administrator of the auto accessories management system They want to have a registration interface that includes the input data of user name, password, confirm password and phone number After registering, they want the data to be saved to a file with the extension txt They want to login successfully when entering pre-registered or pre-existing information They want to report an error if the login or registration form is missing information, or the wrong user name or password is entered When accessing the system, some exceptions such as file not found are set if present After successful login, the system will display the main interface including functions such as add new, edit, delete, delete all They want some other extra functions such as sorting and searching based on the information of auto accessories The exit button is used to exit the program, the logout button will return to the login interface III UI design Figure 1: Login interface Figure 2: Sign Up interface Figure 3: Home page interface VI Implementation Figure 4: Flow of system Program structure The user will start with the login interface or the signup interface With the signup interface, the user will enter the registration information and register an account, after registration, the information will be saved to the txt file and navigate to the login page The user will enter an already registered or pre-registered account After successful login, the system will redirect to the main page containing the functions of the car management system To perform any function the user has to enter a new product and save it in the table With Edit, select the product you want to edit, edit and update the product With Delete, select the product you want to delete, click delete to delete the product With Delete all, there is no need to select the product Select Sort, then click on the column names to sort from a-z or 0-9 or vice versa Write the key word you want to find in the search box, the corresponding product will appear automatically The user can return to the login interface with the logout button or exit the workflow with the exit button Explain classes The system is implemented based on classes type Model Figure 5: Classes The LoginModel.java class is used to set and get data from the input and call it in the View, it is also used to hash the user name and password It has public functions such as constructor (for initialization), set and get functions to retrieve data from view and tea it back (for storage and use purposes) There are also a number of other functions such as hash code for encrypting data, applying to passwords and usernames Figure 6: LoginModel class The MainModel.java class has the main function of setting and getting the product's data, storing it for the Home Page to call out and providing the algorithms Figure 7: MainModel class Like LoginModel class, Main Model also has constructor, set, get function to store, use data Datas is ID, accessory, category, publisher, cost Explain important algorithms a) Login function At the beginning, the LoadData function will be run to load the file, providing data for the login algorithm Figure 8: Login function (part 1) A List distortion will be initiated to work with LoginModel The file is also created for writing and reading Figure 9: Login function (part 2) After entering the account into the input cells and clicking login button, the system will retrieve information from the input, initialize an object of LoginModel, transmit to its constructor login data 10 If the user name or password is empty, the message will enter enough information to continue Check if the data from the txt file has and contains the corresponding login information, open the home page and close the login interface, if wrong, the error message b) Signup with write file Figure 10: Signup function When the user clicks on the registration button, the system goes to the corresponding function First, take the data from the input into the variables for processing Check if the data exists or not, if false, the message enters enough data to continue If true, continue to check if the password is the same as a repassword, if it is wrong, the error message, if dangling, create LoginModel objects, the accompanying data is username, password, phone number Call out the setAccount function with object created for storage to the file Figure 11: setAccount function With input data being an object of LoginModel, check the object containing the file to see if there is null or not If Null, create a new arraylist After checking the conditions, add the object to the object containing the file Next use the WriteDataToFile function to write data into the file 11 Figure 12: wirteDataToFile function This algorithm writes data to a file The try-catch command is used to show an error that occurred while writing data to the activity file Create a fos stream to write data to the file specified by FILE_NAME, create an oos stream to read the data that the file output stream is just for doing, this is then filtered through the objectoutputstream, writeObject() of the objectoutputstream class writes the private field c) Add function When the user clicks the add button, the system takes the data from the input saved to the variable check that the data is empty, if empty, require sufficient input Initializing objects with data are the variables of the product If ActionState is ADD, check if the product already exists in the file If it already exists, the message, if it does not exist, proceed to add to object and implement showAccessory function Figure 13: Add function 12 Create objects that take data from MainModel, add to the table Figure 14: showAccessory function If ActionState is EDIT, then perform a product update, implement updateAccessory, it is used for the editing function Then delete the old dataset at the input to enter the new data Create objects that take data from MainModel, update to the index of row of table Figure 15: updateAccessory function d) Edit function Figure 16: Edit function 13 When you click the edit button, the system will check the List to see if it is empty or not, if empty, add the product Take the index from the selected product, if the index = - means that there is no selected index and no product is selected, then the product selection message Proceed to setText and perform ActionState EDIT e) Delete and Delete all function Figure 17: Delete function With Delete function, the system checks whether the table has data, if any, take the index of the selected line, displays a confirmDialog to confirm, if the user chooses Yes, remove the index line at the list and table If the line is not selected, the system will notify you Figure 18: Delete all function 14 With delete all function, check if the table (list) already has data, if there is no data, the message is empty If there is data, display a confirmDialog to confirm If you choose Yes, use the for ring to remove each line in the table Then clear accessory and fireTabledataChanged for table f) Sort and search function Figure 19: Sort function When clicking Sort, performing a function available is setAutoCreateRowSorter (true), the system will allow to arrange a select column in order from a-z or ascend Figure 20: Search function When a user enters data into the input search box, deploy the search function, declaring a DefaultTableModel object Then declare a TableRowSorter object, using setRowSorter and setRowFilter functions to sort by line with data containing input data from input search g) Load file The read file function is called when the LoginPageViewFrm is initialized for the purpose of reading the user account's data from the txt file Figure 21: LoadData function 15 At try: Create fis to read data of txt file, then create ios stream to read data which FileInputStream is just for doing, this stream is then filtered through ObjectInputStream The readObject() method of the ObjectInputStream class reads the personal field At catch: When file doesn’t exits, system will show a message In addition, IO and ClassNotFound exception also use to show errors h) Write file This algorithm writes data to a file The try-catch command is used to show an error that occurred while writing data to the activity file At try: Create a fos stream to write data to the file specified, create an oos stream to read the data that the file output stream is just for doing, this is then filtered through the objectoutputstream, writeObject() of the objectoutputstream class writes the private field Figure 22: WriteData Function At catch: Use exceptions are FileNotFound and IO to show error when file not found or IO error Explain how to handle errors Some if else and Exception error messages will be covered 4.1 Error of if/else With SignUp, if the input lacks information, it will report an error of lack of information, if the password or repassword is wrong, the message will be wrong The notifications are displayed by JOptionPane 16 Figure 23: Error of if/else (part 1) With delete function, if the line to delete has not been selected, the notification system selects row, if the table does not have data, the list message is empty Figure 24: Error of if/else (part 2) 4.2 Error of Exception Figure 25: Error of Exception When loading the file, if the file has not been initialized, there will be exception FileNotFound and notifications There are also some other Exceptions such as not finding class or IOException These are the exceptions used in this program V Testing Table 1: Test case Test case Object Description Test data 17 Expected result Actual result Evaluation Signup Not enter any null information Signup Enter information and Username :a and login Password: a SignIn RePassword: a PhoneNumber:0 SignIn Check Delete File FileNotFoundException Add new Add product into table Any information of product Update Update a product Choose a product Delete Not selected row, click update Sort Sort column ID Search Search a key “zzzz” Exit Exit program Click exit Message Message Login successful Pass Username or password invalid Message Message “sign up” “sign up” Table has As this data Expected Fail Update successful Message error Update successful As expected Pass Sort successful Table does not show any product Out program As expected As expected Pass As expected Pass Pass Pass Pass Pass Evaluation: The main functions such as add, update, delete, delete, sort, search work well, as expected Functions such as login, signup also work well but there are errors in loading files and writing files All errors have been corrected VI Result 18 Successful registration, notification and redirect to login Figure 26: Signup successful Figure 27: Login Successful Enter the registered account or register before to log in, enter correctly, the registration message is successful and redirect to the main page Then perform system functions like Add, edit, delete, search, sort, etc 19 Figure 28: Home page Figure 29: Insert successful 20 ... z to a 22 Figure 34: Search key "a" 23 I Introduction In this assignment, the problem is to develop an application to solve a business problem of auto accessories... classes The system is implemented based on classes type Model Figure 5: Classes The LoginModel .java class is used to set and get data from the input and call it in the View, it is also used to... for encrypting data, applying to passwords and usernames Figure 6: LoginModel class The MainModel .java class has the main function of setting and getting the product''s data, storing it for the Home

Ngày đăng: 04/11/2022, 10:06

w