当前位置:网站首页>"Food alliance ordering system"
"Food alliance ordering system"
2022-07-29 00:32:00 【Chihiro~~】
“ Food alliance ordering system ” Requirement specification
Now we have entered the network era , Online shopping 、 Watch the news 、 Making friends and other people's daily life has been inseparable from the network .“ Just point your fingers , Can deliver meals to the door ”, Ordering meals online is becoming more and more popular among urban young people Now we are developing an online ordering system , Its specific functions are as follows :
- I want to order
Complete the user's order , Each order contains the following information :
Name of the orderer : Ask the user to enter
Choose dishes and servings : Display three menu serial numbers 、 name 、 The unit price 、 Number of likes , Prompt the user to enter the serial number and number of dishes to be selected
Delivery time : Request the same day 10 To 20 The meal is delivered at one o'clock , Ask the user to enter 10~20 The integer of , Input error , Repeat input .
Delivery address : Ask the user to enter
state : Two kinds of state :0: It has been booked ( Default state ) 1、 Completed ( The order has been signed )
Total sum :
Total sum = Unit price of dishes * Additional copies - Meal delivery fee
( Meal delivery fee : When the amount of a single order reaches 50 Yuan time , Free meals , otherwise , To be paid 6 RMB free meals )
After ordering successfully , Display order information .
- Check the order
Traversal shows that there are orders
The content includes : Serial number 、 Name of the orderer 、 Ordering information ( The name of the dish and the number of servings )、 Delivery time 、 Delivery address 、 state ( Scheduled or completed )、 Total sum
- Sign the order
Change the status of the order to completed
- Delete order
The user enters the order number , If the order of this serial number is completed , You can delete , Give corresponding prompt information in other cases
- I want to like
Display the sequence number of dishes 、 Dish name 、 The unit price 、 Number of likes , Prompt the user to enter the sequence number of the dishes you like to complete the likes of the dishes .
- Exit the system
Exit the whole system , Show “ Thank you for using. , looking forward to your next visit ”.
- Menu switching
According to the displayed main menu , Enter the function number to execute the corresponding function , When the input 1~5 when , Perform corresponding functions ( Pictured 1 Shown ).

chart 1 Input 1~5 Function number between , Perform corresponding functions
Such as the input 6 Or other numbers , Exit the system ( Pictured 2 Shown ).

chart 2 Input “6” Or other numbers , Exit the system
When user input 1~5 Function number between , When the function is finished , Show “ Input 0 return ”( Pictured 1 Shown ), When the input 0, Then return to the main menu ( Pictured 3 Shown ), otherwise , Exit the system

chart 3 Input “0” Back to main menu
Code implementation :
package com.hmy.ordering;
import java.util.Scanner;
public class OrderingMsg {
public static void main(String[] args) {
// Data subject , A set of order information
String[] names = new String[4];// The orderer
String[] dishMegs = new String[4];// Ordering information
int[] times = new int[4];// Delivery time
String[] addresses = new String[4];// Delivery address
int[] states = new int[4];// The order status :0 Indicates that you have booked ,1 Indicates completed
double[] sumPrices = new double[4];// Total sum
// Initialize two order information
names[0] = " Chihiro ";
dishMegs[0] = " Yu-Shiang Shredded Pork 1 Share ";
times[0] = 12;
addresses[0] = " Hefei one yuan ";
states[0] = 1;
sumPrices[0] = 24.0;//18.0+6
names[1] = " Chihiro ";
dishMegs[1] = " Braised Hairtail in Brown Sauce 2 Share ";
times[1] = 12;
addresses[1] = " Peking blue bird ";
states[1] = 0;
sumPrices[1] = 76.0;//38.0*2
// Data subject , A set of food information
String[] dishNames = {" Braised Hairtail in Brown Sauce ", " Yu-Shiang Shredded Pork ", " vegetables in season "};
double[] prices = {38.0, 18.0, 10.0};
int[] praiseNums = new int[3];
int num = -1;// Record the number entered by the user
Scanner sc = new Scanner(System.in);
out:
do {
// Show main menu
System.out.println("******************************");
System.out.println("1、 I want to order ");
System.out.println("2、 Check out the food bag ");
System.out.println("3、 Delete order ");
System.out.println("4、 Sign the order ");
System.out.println("5、 I want to like ");
System.out.println("6、 Exit the system ");
System.out.println("******************************");
// Prompt the user to enter the desired operation
System.out.println(" Please select :");
int choose = sc.nextInt();
boolean falg = true;//true Indicates that no empty location was found
switch (choose) {
case 1:
// I want to order
System.out.println("***** I want to order *****");
// Find an empty location , Perform the insert operation
for (int i = 0; i < names.length; i++) {
if(names[i] == null) {
falg = false;
// Display all available product information
System.out.println(" Serial number \t\t Dish name \t\t The unit price \t\t Number of likes ");
for (int j = 0; j < dishNames.length; j++) {
System.out.println((j + 1) + "\t\t" + dishNames[j] +"\t\t" + prices[j] + " element \t\t" + praiseNums[j] + " Fabulous ");
}
// Perform the insert operation
System.out.println(" Please select the serial number of the meal you want to order :");
int orderNum = sc.nextInt();
System.out.println(" Please enter the number of meals :");
int number = sc.nextInt();
String dishMeg = dishNames[orderNum - 1] + " " + number + " Share ";
System.out.println(" Please enter the name of the orderer :");
String name = sc.next();
int time;
while(true) {
System.out.println(" Please choose the delivery time (10-20 Integer between ):");
time = sc.nextInt();
if(time < 10 || time > 20) {
System.out.println(" I'm sorry , The reservation time you entered is incorrect , Please re-enter 10-20 Integer between :");
}else {
break;
}
}
System.out.println(" Please enter your delivery address :");
String address = sc.next();
// Calculate meal expenses
double sumPrice = prices[orderNum - 1] * number;
Double deliPrice = sumPrice > 50 ? 0.0 : 6.0;
// Display order information
System.out.println(" The meal was ordered successfully !");
System.out.println(" What's your order :" + dishMeg);
System.out.println(" The orderer :" + name);
System.out.println(" Delivery time :" + time + " spot , Please sign for it in time ");
System.out.println(" The delivery address is :" + address);
System.out.println(" The total cost of the meal is :" + (sumPrice + deliPrice) + ", The meal cost is " + sumPrice + " element , The delivery fee is :" + deliPrice + " element ");
// Add the data to the corresponding position of the array
names[i] = name;
dishMegs[i] = dishMeg;
times[i] = time;
addresses[i] = address;
sumPrices[i] = (sumPrice + deliPrice);
break;
}
}
// There's no empty space , Can't insert
if(falg) {
System.out.println(" I'm sorry , Your bag is full !");
}
break;
case 2:
// Check out the food bag
System.out.println("***** Check out the food bag *****");
System.out.println(" Serial number \t\t The orderer \t\t Ordering information \t\t Delivery time \t\t Delivery address \t\t Total sum \t\t The order status ");
for (int i = 0; i < names.length; i++) {
String state = states[i] == 0 ? " Booked " : " Completed ";
if(names[i] != null) {
System.out.println((i + 1) + "\t\t" + names[i] + "\t\t" + dishMegs[i] + "\t\t" + times[i] + " spot \t\t" + addresses[i] + "\t\t" + sumPrices[i] + " element \t\t" + state);
}
}
break;
case 3:
// Delete order
System.out.println("***** Delete order *****");
System.out.println(" Please enter the serial number of the order to delete :");
int deleteOrderId = sc.nextInt();
int deleteIndex = -1;// The subscript of the order to be deleted
boolean isNotfind = true;// Indicates whether the order is found .true I didn't find
for (int i = 0; i < names.length; i++) {
// The order has been signed , Delete
if(names[i] != null && states[i] == 1 && deleteOrderId == i + 1) {
deleteIndex = i;
isNotfind = false;
break;
}
// The order has been booked but not signed
else if(names[i] != null && states[i] == 0 && deleteOrderId == i + 1) {
System.out.println(" The order you selected has not been signed , Can't delete !");
isNotfind = false;
break;
}
}
// Order not found
if(isNotfind) {
System.out.println(" I'm sorry , This order does not exist !");
}
// Delete
if(deleteIndex != -1) {
for(int i = deleteIndex; i < names.length - 1; i++) {
names[i] = names[i + 1];
dishMegs[i] = dishMegs[i + 1];
times[i] = times[i];
addresses[i] = addresses[i + 1];
states[i] = states[i + 1];
}
// Empty the last position of the array
names[names.length - 1] = null;
dishMegs[names.length - 1] = null;
times[names.length - 1] = 0;
addresses[names.length - 1] = null;
states[names.length - 1] = 0;
System.out.println(" Order deleted successfully !");
}
break;
case 4:
// Sign the order
System.out.println("***** Sign the order *****");
System.out.println(" Please enter the order serial number to sign :");
int signOrderId = sc.nextInt();
boolean notfind = true;// Indicates whether the order is found .true I didn't find
for (int i = 0; i < names.length; i++) {
// The order has been signed
if(names[i] != null && states[i] == 1 && signOrderId == i + 1) {
System.out.println(" The order you selected has been signed , Can't sign again !");
notfind = false;
break;
}
// The order has been booked but not signed
else if(names[i] != null && states[i] == 0 && signOrderId == i + 1) {
states[i] = 1;
System.out.println(" Your order was signed successfully !");
notfind = false;
break;
}
}
// Order not found
if(notfind) {
System.out.println(" I'm sorry , This order does not exist !");
}
break;
case 5:
// I want to like
System.out.println("***** I want to like *****");
// Display all the product information that you can choose to like
System.out.println(" Serial number \t\t Dish name \t\t The unit price \t\t Number of likes ");
for (int i = 0; i < dishNames.length; i++) {
System.out.println((i + 1) + "\t\t" + dishNames[i] +"\t\t" + prices[i] + " element \t\t" + praiseNums[i] + " Fabulous ");
}
System.out.println(" Please enter the serial number of the food you like :");
int praiseId = sc.nextInt();
praiseNums[praiseId - 1]++;// Like number plus 1
System.out.println(" I like it !");
break;
case 6:
// User input 6 Exit the system
System.out.println("***** Exit the system *****");
break out;
default:
// User input 1-6 Other numbers exit the loop
break out;
}
// Prompt the user for input 0 Go back and continue
System.out.println(" Input 0 return :");
num = sc.nextInt();
}while(num == 0);
// Input not 0 The exit
System.out.println(" Thank you for using. , looking forward to your next visit !");
}
}
边栏推荐
- Attack and defense world web master advanced area web_ php_ include
- PTA (daily question) 7-69 narcissus number
- 分布式限流 redission RRateLimiter 的使用及原理
- 时间序列统计分析
- Detailed explanation of the usage of exists in MySQL
- Introduction and solution of common security vulnerabilities in web system CSRF attack
- PHP语言基础知识(超详细)
- Use hutool tool class to operate excel with more empty Sheet1
- Advanced area of attack and defense world web masters unserialize3
- 还在写大量 if 来判断?一个规则执行器干掉项目中所有的 if 判断...
猜你喜欢

Kali installs burpsuite professional

MySQL事务(transaction) (有这篇就足够了..)

Dynamic programming (V)

PTA (daily question) 7-75 how many people in a school

动态规划问题(六)

MySQL stored procedure

PTA (daily question) 7-73 turning triangle

Advanced area of attack and defense world web masters unserialize3
![[small bug diary] Navicat failed to connect to MySQL | MySQL service disappeared | mysqld installation failed (this application cannot run on your computer)](/img/ac/f63e370df72ace484a618cf946d4b7.png)
[small bug diary] Navicat failed to connect to MySQL | MySQL service disappeared | mysqld installation failed (this application cannot run on your computer)

Laravel8 middleware realizes simple permission control
随机推荐
MySQL installation and configuration tutorial (super detailed, nanny level)
动态规划问题(五)
Idea2021.2 installation and configuration (continuous update)
动态规划问题(八)
Newscenter, advanced area of attack and defense world web masters
2022dasctfjuly empowerment competition (reappearance)
Advanced area of attack and defense world web masters warmup
Applet verification code login
vulnhub:Sar
Advanced area of attack and defense world web masters training www robots
12个MySQL慢查询的原因分析
Oracle super full SQL, details crazy
Why is it so difficult for the SEC to refuse the application for transferring gray-scale GBTC to spot ETF? What is the attraction of ETF transfer?
Dynamic programming problem (6)
[small bug diary] Navicat failed to connect to MySQL | MySQL service disappeared | mysqld installation failed (this application cannot run on your computer)
Introduction and solution of common security vulnerabilities in Web System SQL injection
PTA (daily question) 7-71 character trapezoid
PTA (daily question) 7-74 yesterday
MySQL的存储过程
vscode下链接远程服务器安装插件失败、速度慢等解决方法