找不到符号错误?

时间:2014-01-25 20:48:08

标签: java compiler-construction compiler-errors

编译器说它无法在代码上找到Getdata。不知道为什么?

确切的错误是:

Inventory.java:18: error: cannot find symbol
            int i = GetData.getInt(menu);
                    ^
symbol:   variable GetData
location: class Inventory

代码:

import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;

class Inventory
{
  public static void main(String arg[])
  {
    Database db = new Database();
    Database dpl = new Database();

    String menu = "1. Add product\n2. Sell product\n3. Delete product\n4. Modify  product\n5. Display information\n6. Exit";
    boolean more = true;

    while(more)
    {
        int i = GetData.getInt(menu);
        switch(i)
        {
            case 1:
                   // Creating an order and additing this order to the database
                   IO.display("Add new product", "New product", JOptionPane.INFORMATION_MESSAGE);

                    String street = GetData.getWord("Enter street address");
                    String city = GetData.getWord("Enter city");
                    String state = GetData.getWord("Enter state");
                    String zip = GetData.getWord("Enter zip code");
                    Address addr = new Address(street, city, state, zip);

                    String company_name =  GetData.getWord("Enter name of the company");
                    Manufacturer m = new Manufacturer(addr, company_name);

                    String product_name =  GetData.getWord("Enter name of product");
                    String product_code =  GetData.getWord("Enter product code: xx-xxx-xxxx");
                    double price = GetData.getInt("Enter unit price");

                    Product p = new Product(m,  product_name,  product_code, price);

                     int quantity =  GetData.getInt("Enter quantity");

                     Order ord = new Order(p, quantity);

                    db.add(ord);
            break;
            case 2:

            break;
            case 6:
                    more = false;
            break;

            default:
            break;
          } // End switch
      } // End while
  } // End main

    static void display(String s, String ss, int m){}
} // End inventory

1 个答案:

答案 0 :(得分:1)

您必须先使用所有方法定义GetData类才能使用它。