Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Java to make a foodie Alliance reservation system

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use Java to do a foodie alliance reservation system, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

I. Preface

Just finished learning the basic introduction to java, mainly learning Java basic environment building, defining variables, selection structure, loop structure, array and so on. At the end of this stage, I tried to contact the foodie Alliance reservation system. I hit such a long code for the first time. I wish I had more knowledge later. Work hard!

Foodie Alliance reservation system includes the functions: I want to order, check the meal bag, sign the order, delete the order, I want to like, exit the system

II. Basic business analysis

I would like to order a meal

1. Enter the name of the ordering person

two。 Display all the dishes

3. Enter the serial number of the dish to be ordered

4. Enter the number of dishes to be ordered

5. Enter delivery time

6. Enter the shipping address

7. Display reservation information

Check the meal bag.

1. Display all order information directly

I want to sign for it.

1. Show all order information

two。 Enter the order number to be signed for

3. If it has been completed, repeated signing is not allowed.

4. If it is not finished, you can sign for it.

5. Show the success of signing

Delete order

1. Show all order information

two。 Enter the order number to be deleted

3. Delete is not allowed if not completed (subscribed)

4. If completed, you can delete the order.

5. Show successful deletion

I want to like it.

1. Show all the food information

two。 Enter the serial number of the dish you like.

3. Prompt likes successfully

Exit the system

1. Hint concluding remarks

two。 Executive program exit

3. Complete code public class OrderingMsg {public static void main (String [] args) {/ / initialization data / / data body: a set of order information String [] names = new String [4]; / / name of the order person String [] dishMegs = new String [4] / / selected dishes int [] times = new int [4]; / delivery time String [] addresses = new String [4]; / delivery address int [] states = new int [4]; / / order status: 0 pre-ordered 1 completed double [] sumPrices = new double [4] / / Total amount / / initialize two order information names [0] = "Galen"; dishMegs [0] = "Braised Ribbonfish in Brown Sauce 2"; times [0] = 3; addresses [0] = "Demacia"; sumPrices [0] = 76.0 States [0] = 1; names [1] = "Lux"; dishMegs [1] = "Braised Ribbonfish in Brown Sauce 1 copy"; times [1] = 10; addresses [1] = "Demacia"; sumPrices [0] = 20 / / Food information to choose from String [] dishNames = {"Braised Ribbonfish in Brown Sauce", "Yu-Shiang Shredded Pork", "seasonal vegetables"}; / / vegetable unit price double [] prices = new double [] {38.0 prices 20.0 10}; int [] praiseNums = new int [3] Scanner input = new Scanner (System.in); / / enter 0 to return to the main menu, otherwise exit the system int num =-1; / / mark whether the user proposes the system true: exit the system boolean isExit = false; System.out.println ("Welcome to foodie Alliance system") / / Loop: display menu, execute response function according to user's choice, do {/ / display menu System.out.println ("*"); System.out.println ("1: I want to order") System.out.println ("2: check the meal bag"); System.out.println ("3: sign the order"); System.out.println ("4: delete the order"); System.out.println ("5: I want to like") System.out.println ("6: exit the system"); System.out.println ("*"); System.out.println ("Please select:") / / record the customer selection function number int choose = input.nextInt (); / / record the user selection function number boolean isAdd = false; / / find the order to be signed boolean isSignFind = false / / find the order to be deleted boolean isDelFind = false / / execute response function switch (choose) {case 1: / / I want to order a meal System.out.println ("*") according to the function number selected by the user. * * I'd like to order a meal * ") / / Loop display menu for (int j = 0; j 0? praiseNums [I] + "likes"; System.out.println ((iLiqu1) + "+ dishNames [I] +" + price+ "" + priaiseNum) } / / user order System.out.println ("Please select the dish number you ordered:") Int chooseDish = input.nextInt (); System.out.println ("Please select the number of copies you want:"); int number = input.nextInt () String dishMeg = dishNames [chooseDish-1] + "+ number+"; double sumPrice = prices [chooseDish-1] * number / / meal fee over 50 yuan, free meal charge 10 yuan double deliCharge = (sumPrice > = 50)? 0 System.out.println 6; System.out.println ("Please enter the delivery time (delivery time is from 10:00 to 20:00 sharp:)") Int time = input.nextInt (); while (time20) {System.out.println ("you typed it incorrectly, please enter an integer between 10 and 20!") Time = input.nextInt ();} System.out.println ("Please enter delivery address:"); String address = input.next () / / there is no need to add status. The default is 0, that is, the booked status. System.out.println ("successful booking!"); System.out.println ("your order is: + dishMeg); System.out.println (" delivery time is: "+ time+") System.out.println ("meal fee:" + sumPrice+ "yuan, delivery fee" + deliCharge+ "yuan, total:" + (sumPrice+deliCharge) + "yuan"); / / add data names [j] = name DishMegs [j] = dishMeg; times [j] = time; addresses [j] = address; sumPrices [j] = sumPrice+deliCharge; break }} if (! isAdd) {System.out.println ("Sorry, your meal bag is full!") } break; case 2: / / check the meal bag System.out.println ("* check the meal bag *") System.out.println ("order number, food information, delivery time, total order status"); for (int I = 0; I

< names.length; i++) { //查看餐袋中的内容,如果是空就跳出,不在查看 if (names[i]==null) { String state = (states[i]==0)?"已预定":"已完成"; String data = times[i]+"日"; String sumPrice = sumPrices[i]+"元"; System.out.println((i+1)+" "+names[i]+" "+dishMegs[i]+" "+addresses[i]+" "+sumPrice+" "+state); } } break; case 3: //签收订单 System.out.println("*********签收订单**********"); System.out.println("请选择要签收的订单序号:"); int signOrder = input.nextInt(); for (int i = 0; i < names.length; i++) { //状态为已预定,序号为用户输入的订单序号:可签收 //状态为已完成,序号为用户输入订单序号:不可签收 if (names[i]!=null&&states[i]==1&&signOrder==i+1) { System.out.println("您选择的订单已完成签收,不能再次签收"); isSignFind = true; } } //未找到的订单序号:不可签收 if (!isSignFind) { System.out.println("您选择的订单不存在!"); } break; case 4: //删除订单 System.out.println("*********删除订单**********"); System.out.println("请输入要删除的订单序号:"); int delId = input.nextInt(); for (int i = 0; i < names.length; i++) { //状态值为已完成 选侯志为用户输入的序号:可删除 //状态值为已预定 序号值为用户输入的序号:不可删除 if (names[i]!=null&&states[i]==1&&delId==i+1) { isDelFind = true; //执行删除操作:删除位置后的元素依次前移 for (int j = delId+1; j < names.length-1; j++) { names[j] = names[j+1]; dishMegs[j] = dishMegs[j+1]; times[j] = times[j+1]; addresses[j] = addresses[j+1]; states[j] = states[j+1]; } //最后一位清空 names[names.length-1] = null; dishMegs[dishMegs.length-1] = null; times[names.length] = 0; addresses[names.length-1] = null; states[names.length-1] = 0; System.out.println("删除订单成功!"); break; }else if (names[i]!=null&&states[i]==0&&delId==i+1) { System.out.println("您选择的订单未签收,不能删除!"); isDelFind = true; break; } } //未找到该序号的订单,不能删除 if (isDelFind) { System.out.println("您要删除的订单不存在!"); } break; case 5: //我要点赞 System.out.println("*********我要点赞**********"); //显示菜品信息 System.out.println("序号"+" "+"菜名"+" "+"单价"); for (int i = 0; i < dishNames.length; i++) { String price = prices[i]+"元"; String praiseNum = (praiseNums[i])>

0? praiseNums [I] + "like": "; System.out.println ((irais1) +" + dishNames [I] + "+ price+"+ praiseNum);} System.out.println (" Please select the serial number of the dish you want to like: ") Int praiseNum = input.nextInt (); praiseNums [praiseNum-1] + +; / / likes + 1 System.out.println ("like successfully"); break Case 6: / / exit the system isExit = true; break; default: / / exit the system isExit = true Break;} if (isExit) {System.out.println ("return 0 output:"); num = input.nextInt () } else {break;}} while (num==0); System.out.println ("Thank you for using, Welcome next time");}} IV. Shortcut keys for eclipse

1. Declaration to complete the code: alt + /

two。 Quick fix: ctrl + 1

3. Batch guide package: ctrl + shift + o

4. Use single-line comments: ctrl + /

5. Use multiline comments: ctrl + shift + /

6. Uncomment multiline: ctrl + shift +

7. Copy the code for the specified line: ctrl + alt + down or ctrl + alt + up

8. Delete the code for the specified line: ctrl + d

9. Move code up and down: alt + up or alt + down

10. Switch to the next line of code space: shift + enter

11. Switch to the previous line of code space: ctrl + shift + enter

twelve。 How to view the source code: ctrl + select the specified structure or ctrl + shift + t

13. Go back to the previous edited page: alt + left

14. Go to the next edited page (for the above one): alt + right

15. Select the specified class with the cursor to view the inheritance tree structure: ctrl + t

16. Copy code: ctrl + c

17. Undo: ctrl + z

18. Reverse undo: ctrl + y

19. Cut: ctrl + x

20. Paste: ctrl + v

21. Save: ctrl + s

twenty-two。 Select all: ctrl + a

23. Format code: ctrl + shift + f

24. Select several lines and move the whole back: tab

25. Select several lines and move forward as a whole: shift + tab

twenty-six。 In the current class, displays the class structure and supports searching for specified methods, properties, etc.: ctrl + o

twenty-seven。 Batch modify the specified variable name, method name, class name, etc.: alt + shift + r

twenty-eight。 Case switch of the selected structure: become uppercase: ctrl + shift + x

twenty-nine。 Case switch of the selected structure: make it lowercase: ctrl + shift + y

thirty。 Call out and generate getter/setter/ constructor and other structures: alt + shift + s

thirty-one。 Displays the properties of the currently selected resource (project or file): alt + enter

thirty-two。 Quick find: refer to the selected Word and quickly navigate to the next one: ctrl + k

thirty-three。 Close the current window: ctrl + w

thirty-four。 Close all windows: ctrl + shift + w

thirty-five。 Check where the specified structure has been used: ctrl + alt + g

thirty-six。 Find and replace: ctrl + f

thirty-seven。 Maximize the current View:ctrl + m

thirty-eight。 Navigate directly to the first place of the current line: home

thirty-nine。 Navigate directly to the last bit of the current line: end

Thank you for reading this article carefully. I hope the article "how to use Java to make a foodie Alliance reservation system" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report