gpt4 book ai didi

java - 找不到符号错误?

转载 作者:行者123 更新时间:2023-12-01 13:34:59 24 4
gpt4 key购买 nike

编译器表示在代码中找不到 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

最佳答案

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

关于java - 找不到符号错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21356065/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com