JAVA - Elementy, które nie są poprawnie wpisane na listę?

To rodzaj kontynuacjito pytanie. Udało mi się rozgryźć całe pole JTextField, które nie pozwoliło mi wprowadzić żadnego problemu. Teraz mam osobny problem, że przedmiot nie jest poprawnie wprowadzany na listę.

Nadal uważam, że powinniście na to patrzećrepozytorium GitHub ponieważ zamieszczam tu tylko niewielką część kodu, ale oto przynajmniej odpowiednie części.

Tutaj jestGUI program (lub przynajmniej odpowiednie części):

import java.awt.event.*;
import javax.swing.*;

public class GUI extends JPanel implements ActionListener {
    LinkedList<FoodItem> foodItemList = new LinkedList<FoodItem>();
    ...
    protected JTextField textField;
    public GUI() {
        textField = new JTextField(20);
        textField.addActionListener(this);
        add(textField);
        ...
    }
    boolean textSubmitted = false;
    String current_command = "";
    Simulator helper = new Simulator();
    String text = "";
    double p = 0.0;
    int q = 0;
    String d = "";
    double s = 0.0;
    String so = "";
    String c = "";
    ...
    public void add_c() {
        textSubmitted = false;
        current_command = "";
        c = text;
        helper.add(foodItemList, text, p, q, d, s, so, c);
    }
    ...
    public void actionPerformed(ActionEvent e) {
        String command = e.getActionCommand();
        if (command.equals(buttonCommands[0]))  {
            text = textField.getText();
            textSubmitted = true;
            textField.setText("");
            ...
            else if (current_command.equals("add6"))
            add_c();
            ...
        }
        ...
    }
    public static void createAndShowGUI() {
        JFrame frame = new JFrame("Vendor Interface");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        GUI newContentPane = new GUI();
        newContentPane.setOpaque(true);
        frame.setContentPane(newContentPane);
        frame.pack();
        frame.setVisible(true);
    }
}

Tutaj jestSimulator program:

public class Simulator {
    public void add(LinkedList<FoodItem> fi, String text, double p, int q, String d, double s, String so, String c) {
        fi.add(new FoodItem(text,p,q,d,s,so,c));
    }
    ...
}

OtoLinkedList:

public class LinkedList <T> implements LinkedListInterface <T> {
    public LinkedListNode <T> list;
    ...
    @Override
    public void add(T element) {
        if (!contains(element)) {
            LinkedListNode <T> newNode = new LinkedListNode<T>(element, list);
            list = newNode;
            count++;
        }
        else
            System.out.println("Element is already included.");
    }
    @Override
    public boolean contains(T element) {
        LinkedListNode<T> current = list;
        if (!isEmpty()) {
            while (current != null) {
                if (current.getElement().equals(element))
                    return true;
                current = current.getLink();
            }
        }
        return false;
    }
    public boolean containsName(String s)   {
        LinkedListNode<T> current = list;
        if (isEmpty())
            return false;
        else    {
            while (current != null) {
                if (current.getElement().getClass().getName().equals("FoodItem"))   {
                    FoodItem fi = (FoodItem) current.getElement();
                    if (fi.name.equals(s))
                        return true;
                }
            current = current.getLink();
            }
            return false;
        }
    }
    ...
    @Override
    public boolean isEmpty() {
        if (list == null)
            return true;
        else
            return false;
    }
...
}

OtoLinkedListNode:

public class LinkedListNode <T>{
    T element;
    LinkedListNode <T> link;
    public LinkedListNode(T element) {
        super();
        this.element = element;
        this.link = null;
    }
    public LinkedListNode(T element, LinkedListNode <T> link) {
        super();
        this.element = element;
        this.link = link;
    }
    public T getElement() {
        return element;
    }
    public void setElement(T element) {
        this.element = element;
    }
    public LinkedListNode <T> getLink() {
        return link;
    }
    public void setLink(LinkedListNode <T>link) {
        this.link = link;
    }
}

Myślę, że to wszystko, co muszę napisać ... daj mi znać, jeśli jest coś jeszcze!

Z góry dziękuję za pomoc!

questionAnswers(0)

yourAnswerToTheQuestion