已关闭,此问题需要details or clarity。目前不接受答复。
**想改善这个问题吗?**通过editing this post添加详细信息并澄清问题。
15小时前关门了。
Improve this question
嘿我得为学校做这个。我的客户是夫人。妮迪·斯凯哈瓦特她是穆索里伍德斯托克学校的设计老师。作为一名设计老师,她要处理很多原材料。她有100多个容器,里面装着随机的乐高积木和原材料。她也有一个固定的地方来储存这一切。因此,她需要我的帮助来组织所有这些材料,并索引所有原材料的去向。目前,这些盒子和原材料都躺在周围。必须尽快解决这一问题。这是一个巨大的后勤问题,因此,她已经与我签约,帮助她创建一个程序来帮助解决这些问题。Nidhi夫人要求我做一个基于Java的代码,让她输入她拥有的材料数量和存储材料所需的空间。它还应该索引材料并告诉她材料在哪里。她应该输入材料,然后是数量,然后是材料的尺寸。程序应该获取这些信息,并决定这些材料将占用多大的空间,然后询问她希望将其存储在哪里。
这是我目前为止的代码。
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class MaterialOrganizer {
private JFrame frame;
private JPanel panel;
private JLabel titleLabel;
private JLabel nameLabel;
private JLabel quantityLabel;
private JLabel sizeLabel;
private JLabel storageLabel;
private JLabel warningLabel;
private JTextField nameField;
private JTextField quantityField;
private JTextField sizeField;
private JTextField storageField;
private JCheckBox expensiveBox;
private JCheckBox flammableBox;
private JButton addButton;
private JButton searchButton;
private JButton updateButton;
private JButton backupButton;
private JButton restoreButton;
private JTextArea searchResultsArea;
private JScrollPane scrollPane;
private HashMap<String, Material> materials;
private static final int WIDTH = 600;
private static final int HEIGHT = 600;
public MaterialOrganizer() {
// Initialize GUI components
frame = new JFrame();
panel = new JPanel();
titleLabel = new JLabel("Material Organizer");
nameLabel = new JLabel("Material Name:");
quantityLabel = new JLabel("Quantity:");
sizeLabel = new JLabel("Size:");
storageLabel = new JLabel("Storage Location:");
warningLabel = new JLabel(" ");
nameField = new JTextField();
quantityField = new JTextField();
sizeField = new JTextField();
storageField = new JTextField();
expensiveBox = new JCheckBox("Expensive");
flammableBox = new JCheckBox("Flammable");
addButton = new JButton("Add Material");
searchButton = new JButton("Search Material");
updateButton = new JButton("Update Material");
backupButton = new JButton("Backup");
restoreButton = new JButton("Restore");
searchResultsArea = new JTextArea();
scrollPane = new JScrollPane(searchResultsArea);
materials = new HashMap<String, Material>();
// Add components to panel
panel.setLayout(null);
titleLabel.setBounds(0, 10, WIDTH, 30);
titleLabel.setHorizontalAlignment(JLabel.CENTER);
panel.add(titleLabel);
nameLabel.setBounds(100, 60, 120, 30);
panel.add(nameLabel);
nameField.setBounds(230, 60, 200, 30);
panel.add(nameField);
quantityLabel.setBounds(100, 100, 120, 30);
panel.add(quantityLabel);
quantityField.setBounds(230, 100, 200, 30);
panel.add(quantityField);
sizeLabel.setBounds(100, 140, 120, 30);
panel.add(sizeLabel);
sizeField.setBounds(230, 140, 200, 30);
panel.add(sizeField);
storageLabel.setBounds(100, 180, 120, 30);
panel.add(storageLabel);
storageField.setBounds(230, 180, 200, 30);
panel.add(storageField);
expensiveBox.setBounds(100, 220, 100, 30);
panel.add(expensiveBox);
flammableBox.setBounds(230, 220, 100, 30);
panel.add(flammableBox);
addButton.setBounds(100, 270, 120, 30);
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addMaterial();
}
private void addMaterial() {
}
});
panel.add(addButton);
searchButton.setBounds(230, 270, 120, 30);
searchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
public;
我一直在给我看这个C:\Users\Akksh\IdeaProjects\Summ\src\MaterialOrganizer.java:98:23 java:类型的非法开始
我试着google一下……
1条答案
按热度按时间yqhsw0fo1#
您需要删除程序末尾的
public;
语句。您还需要使用}
括号关闭MaterialOrganizer
类、类构造器和ActionListener
事件。修改代码: