简体   繁体   English

找不到符号错误?

[英]Cannot find symbol error?

The compiler says that it cannot find Getdata on the code. 编译器说无法在代码上找到Getdata。 Not sure why? 不知道为什么吗?

The exact error is: 确切的错误是:

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

Code: 码:

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

您必须首先使用所有方法定义GetData类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM