好的,我一直在制作这个程序来从头开始获取一些库存数据,因为教授的帮助代码是垃圾。但我有点卡住了。正如你可以在下面看到的,我的代码将把一些字符串传递给一个名为address的类,它将基本上将该信息编译成单个变量。为我的程序编写一个类JAVA
但是我需要一些帮助来编写那个类,现在我知道这里的大多数海报都不会为我写代码。我不是要求你为我写信,而是请你告诉我如何做到这一点,并举例说明。它会帮助我很多。这也意味着稍后我可以让制造商非常孤单,尽管我知道我会搞砸一点。
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();
final String[] MENU_OPTIONS = {"exit", "Add product", "Sell product", "Delete product", "Modify product",
"Display information"};
final String MENU_NAME = "Inventory";
boolean active = true;
while(active)
{
String selection = promptInventory(MENU_NAME, MENU_OPTIONS);
//logic
switch (selection)
{
case "exit" : active = false;
break;
case "Add product" : // Creating an order and adding this order to the database
IO.display("Add new product", "New product", JOptionPane.INFORMATION_MESSAGE);
String street = IO.getWord("Enter street address");
String city = IO.getWord("Enter city");
String state = IO.getWord("Enter state");
String zip = IO.getWord("Enter zip code");
Address addr = new Address(street, city, state, zip);
// Company stuff
String company_name = IO.getWord("Enter name of the company");
Manufacturer m = new Manufacturer(addr, company_name);
break;
case "Sell product" :
break;
}//switch
}//while loop
}//main
public static String promptInventory(String MName, String[] options)
{
int selection = JOptionPane.showOptionDialog(null,
"Enter your Transaction Type",
MName,
JOptionPane.DEFAULT_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, options, options[0]);
return (String)options[selection];
}//prompt
}//inventory class
请格式化您的代码。 – BitNinja
并请多解释一下你的问题。 – christopher