餐厅点菜管理系统Java语言程序课程设计

餐厅点菜管理系统Java语言程序课程设计

项目功能模块
系统功能模块如下:
(1)权限管理:包括用户的注册、登录、用户信息管理。
(2)点餐功能:包括餐单的增加、修改、删除、查看。
(3)订单管理:包括生成订单、修改、删除、查找。
(4)结账管理:统计消费的总额。
(5)查看历史:查看消费历史。
(6)保存功能:可将当前系统中各类记录存入文件中,存入方式任意。
(7)读取功能:可将保存在文件中的信息读入到当前系统中,供用户进行使用。
在这里插入图片描述

package restaurant;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import java.awt.Font;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

class LoginCheck{
    private String name;
    private String password;
    public LoginCheck(String name,String password){
        this.name=name;
        this.password=password;
    }
    
    
    public boolean equals() throws IOException{
    	String s[],str;
		FileReader fr = new FileReader("register.txt");
		BufferedReader br = new BufferedReader(fr);
		str = br.readLine();
		if(str == null)
		return true;
		s = str.split(",");
		while(str!=null)
        {
			if(s[0].equals(name) && s[1].equals(password))
            {
				FileWriter fw = new FileWriter("login.txt",false);
				BufferedWriter bw = new BufferedWriter(fw);
				str = s[0] + "," + s[1] + "\n";
                bw.write(str);
                bw.flush();
                bw.close();
                fw.close();
            	return true;
            }
			if(s[0].equals(name) && !s[1].equals(password))
            {
            	return false;
            }
			str = br.readLine();
			if(str == null)
			return false;
			s = str.split(",");
		}
        return false;
    }
}

public class appframe extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					appframe frame = new appframe();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public appframe() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton button_1 = new JButton("\u6CE8\u518C");
		button_1.setBounds(229, 171, 113, 27);
		contentPane.add(button_1);
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e){
				if(e.getSource() == button_1){
					{
						new registered();
						setVisible(false);
					 }
					}
				}
			 });
		
		JLabel label = new JLabel("\u9910\u5385\u70B9\u83DC\u7CFB\u7EDF");
		label.setFont(new Font("宋体", Font.PLAIN, 24));
		label.setBounds(142, 23, 144, 36);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("\u7528\u6237\u540D");
		label_1.setBounds(33, 84, 72, 18);
		contentPane.add(label_1);
		
		JLabel label_2 = new JLabel("\u5BC6\u7801");
		label_2.setBounds(33, 128, 72, 18);
		contentPane.add(label_2);
		
		textField = new JTextField();
		textField.setBounds(119, 81, 176, 24);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JPasswordField textField_1 = new JPasswordField();
		textField_1.setBounds(119, 128, 176, 24);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
		
		JButton button = new JButton("\u767B\u5F55");
		button.setBounds(89, 171, 113, 27);
		contentPane.add(button);
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e){
				if(e.getSource() == button){
                    String sname=textField.getText();
                    String spass=new String(textField_1.getPassword());
                    LoginCheck log=new LoginCheck(sname,spass);
                    try {
						if(log.equals()){
						    try {
						        new frame();
						        setVisible(false);
						    } catch (Exception e1) {
						        
						        e1.printStackTrace();
						    }
						    
						}else{
						    JOptionPane.showMessageDialog(null, "登录失败,错误的用户名或密码!");
						    textField_1.setText("");
						}
					} catch (HeadlessException | IOException e1) {
						// TODO 自动生成的 catch 块
						e1.printStackTrace();
					}
                }
			 }
		});
		setVisible(true);
	}
}

  • 6
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
java项目package project.action.dialogAction; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JOptionPane; import project.dao.common.DbException; import project.dao.dataDao.LoginInfoDao; import project.dao.dataDaoImpl.LoginInfoDaoImpl; import project.view.dialog.AddLoginInfoDialog; import project.vo.LoginInfoVo; /** * 添加登录账号action * * @author Administrator * */ public class AddLoginInfoAction implements ActionListener { private AddLoginInfoDialog dialog; public AddLoginInfoAction(AddLoginInfoDialog dialog) { this.dialog = dialog; } public void actionPerformed(ActionEvent e) { String name = e.getActionCommand(); if (name.equals("确定")) { // 检验输入是否正确 if (dialog.checkInputValue()) { LoginInfoDao dao = null; LoginInfoVo vo = null; try { // 获得界面输入信息 vo = dialog.getInputInfo(); String confirm = dialog.getConfirm(); if (vo.getLog_pwd().equals(confirm)) { dao = new LoginInfoDaoImpl(); if (dao.insertLoginInfo(vo)) { // 打印提示信息 JOptionPane.showMessageDialog(null, "添加登录人员成功", "提示信息", JOptionPane.YES_OPTION); dialog.dispose(); } else { // 打印提示信息 JOptionPane.showMessageDialog(null, "添加登录人员失败", "提示信息", JOptionPane.YES_OPTION); } } else { // 如果密码确认输入错误,打印提示信息 JOptionPane.showMessageDialog(null, "密码确认错误,请重新输入", "提示信息", JOptionPane.YES_OPTION); } } catch (DbException ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "提示信息", JOptionPane.YES_OPTION); } } else { JOptionPane.showMessageDialog(null, "请确认输入是否完整正确", "提示信息", JOptionPane.YES_OPTION); } } else if (name.equals("取消")) { dialog.dispose(); } } }
好的,以下是一个简单的Java餐厅点餐管理系统的GUI代码: ```java import java.awt.*; import java.awt.event.*; import javax.swing.*; public class RestaurantGUI extends JFrame implements ActionListener { // 声明组件 private JLabel title; private JLabel nameLabel; private JTextField nameField; private JLabel tableLabel; private JComboBox<String> tableComboBox; private JLabel dishLabel; private JCheckBox[] dishCheckBoxes; private JButton submitButton; private JButton clearButton; // 构造函数 public RestaurantGUI() { // 设置窗口标题 super("餐厅点餐管理系统"); // 设置窗口大小和位置 setSize(400, 400); setLocationRelativeTo(null); // 设置布局 setLayout(new GridLayout(6, 2)); // 添加标题标签 title = new JLabel("欢迎使用餐厅点餐管理系统", JLabel.CENTER); add(title); // 添加姓名标签和文本框 nameLabel = new JLabel("姓名:", JLabel.RIGHT); add(nameLabel); nameField = new JTextField(10); add(nameField); // 添加桌号标签和下拉框 tableLabel = new JLabel("桌号:", JLabel.RIGHT); add(tableLabel); String[] tableNumbers = {"1号桌", "2号桌", "3号桌", "4号桌", "5号桌"}; tableComboBox = new JComboBox<String>(tableNumbers); add(tableComboBox); // 添加品标签和复选框 dishLabel = new JLabel("品:", JLabel.RIGHT); add(dishLabel); String[] dishNames = {"鱼香肉丝", "宫保鸡丁", "糖醋里脊", "回锅肉", "青椒肉丝"}; dishCheckBoxes = new JCheckBox[dishNames.length]; for (int i = 0; i < dishNames.length; i++) { dishCheckBoxes[i] = new JCheckBox(dishNames[i]); add(dishCheckBoxes[i]); } // 添加提交和清空按钮 submitButton = new JButton("提交"); submitButton.addActionListener(this); add(submitButton); clearButton = new JButton("清空"); clearButton.addActionListener(this); add(clearButton); // 显示窗口 setVisible(true); } // 实现ActionListener接口的方法 public void actionPerformed(ActionEvent e) { if (e.getSource() == submitButton) { // 提交按钮被点击,处理提交逻辑 String name = nameField.getText(); String tableNumber = (String) tableComboBox.getSelectedItem(); String selectedDishes = ""; for (int i = 0; i < dishCheckBoxes.length; i++) { if (dishCheckBoxes[i].isSelected()) { selectedDishes += dishCheckBoxes[i].getText() + " "; } } JOptionPane.showMessageDialog(this, "提交成功!\n姓名:" + name + "\n桌号:" + tableNumber + "\n品:" + selectedDishes); } else if (e.getSource() == clearButton) { // 清空按钮被点击,处理清空逻辑 nameField.setText(""); tableComboBox.setSelectedIndex(0); for (int i = 0; i < dishCheckBoxes.length; i++) { dishCheckBoxes[i].setSelected(false); } } } // 程序入口 public static void main(String[] args) { new RestaurantGUI(); } } ``` 这个GUI界面包括姓名、桌号、品等信息的输入和提交、清空按钮的操作。当提交按钮被点击时,会弹出一个对话框显示提交的信息。当清空按钮被点击时,会将输入框和复选框清空。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值