Write a meal ordering system in Java in the computer graduation project (JAVA SWING)

1. Development technology
JDK: JDK1.8, JDK is a software development kit for the Java language, mainly used for java applications on mobile devices and embedded devices. JDK is the core of the entire java development, it includes the JAVA operating environment (JVM+Java system class library) and JAVA tools.

IDE: NetBeans 8.2.0, NetBeans is an open source software development integrated environment and an open framework.

DataBase: JavaDB, the database that comes with Java.

2. Demand analysis

2.2 Function introduction

The dish information management system is mainly divided into the front-end users ordering meals, and the back-end administrators add, delete, modify, check, and count the dish information and user-submitted order information.

1. Dish information management page: you can add dish information, add and drop dishes, modify prices, delete dishes, save dish information to files, sort by sales, etc.

2. Order management interface: The administrator can make statistics of today's income, this month's income, and total income on orders, and can query order information according to time.

3. The back kitchen management interface: you can view the order information submitted by all users today, and arrange the names and remarks of the dishes in the order submitted by the users. The back kitchen can cook and complete the order according to the information submitted by the users in the order.

4. Front-end user order page: including menu display, dish picture preview, adding dishes to the order and changing dishes remarks (special requirements for dishes taste), and real-time statistics of the total consumption amount based on the dishes selected by the user, the dishes displayed on this page They are all the dishes that have been put on the shelves in the backstage. Unlisted dishes will not be displayed in the foreground. After the order is successfully submitted on this page, the sales of the selected dishes will also increase.

5. Login page: Match the account password entered by the user with the account password in the user data table, and enter the background management page if the match is successful.

Three, system design
3.1 structure introduction

The structure is mainly divided into GUI package (store the graphical interface JFRAME and some logical operations), DbQuery package (store all operations to access the database), img package (store icon pictures and display pictures of various dishes) and Db package (store JAVADB database) file).

3.2 Data table structure analysis

The data table is mainly divided into three: dish information table, user order table, and administrator information table.

Insert picture description here

There are five attributes for the dish entity. The first is that the dish number used as the primary key is not empty and not repeated. The price may have decimals, so the price is set to double. For dish sales, it is a relatively small integer, so the INT type can be used. When the user orders a dish, the sales volume will also increase, and the dish on the shelf is a field with only two values, so use Boolean to store. Various types of data may appear in other introductions and names, so set these attributes to string types.

Insert picture description here

For the order information table, because you need to query orders based on time and count order consumption on the order management page, set the order event to Date type and MD format to locate orders for each day. The order table does not treat each dish and price as a field, because the fields in the table cannot be fixed. So I concatenate the user’s dishes and remarks with strings and separate them with, so that when pulling the order data, I can use the split(',') function of the string to obtain a string array, which can achieve any The storage effect of quantity dishes.

Insert picture description here

The administrator information table is used as the login interface to compare strings. It can be simply designed as String type strings. When comparing, compare directly through SQL statements. At the beginning of the permission field, you want to make it and assign different permissions according to different permissions. Function, but found that the logic of assigning permissions is not very complete and not easy to implement, so in the end only the highest-privileged admin was used.

3.3 Analysis of program classes and functions

For the main structure of the program class, MainFrame, DishFrame, OrderDishFrame, DbQuery and other classes are mainly designed. DishFrame includes multiple dialogs, kitchen management (jdialogKitchen), about us (jDialogAbout), order statistics (jdialogOrder), MainFrame is the main interface of the program , Including the main interface and the login interface (JDialogLogin), each dialog also includes the components and triggers of java swing, such as private void jButtonResetActionPerformed (java.awt.event.ActionEvent evt) events triggered by mouse clicks, when This event is triggered when the reset button is clicked, and all the contents of the TextField are changed to empty.

The DbQuery class includes various operations of the database. For example, getConnection is a method to connect to the database, which returns a Connection object, and the addDish(String No, String Name, double Money, boolean dis, String intro) method is used to obtain dish information from the formal parameters. The SQL statement stores it in the data table. The public static String[][] getOrder() method gets all the order information from the database through the "select * from orderdish" SQL statement, and returns it to the calling place in the form of a two-dimensional array, public static Double[] sumUp( The) function can count in the data table order and return a two-dimensional array of daily, monthly, and total consumption.

By importing, instantiating and invoking each other in these three categories, the function and architecture of the entire system are completed.

image

                                    图4.3登录页面

image

                                图4.4后台管理页面

Guess you like

Origin blog.csdn.net/bwwork/article/details/113748446