引用具有两个属性的对象

时间:2013-11-29 14:52:56

标签: java object attributes

我目前有一个小程序来完成销售交易。我有以下对象(store,store_list,sale_item,sale_itemSet,inventory和& inventory_list)。 我需要在指定的 storeID

获取产品的正确价格
Inventory attributes
private String prodName; 
private long prodNo; 
private float prodPrice;
private int storeID; 
private int quantity; 
private int prodReorderLvl; 

主程序看起来像这样

//new transaction
    case 1:
      System.out.println("Enter Store Number: ");
      storeID = in.nextInt();

      //automatically generate sale number
      saleNo = saleS.getNumSales() + 1;

      //reset sale line items before staring loop
      si = new saleItem();
      si.setSaleLine(0); 

      //reset saleAmt to 0
      saleAmt = 0;

      while(yesNo != ('N'|'n'))
      {
        System.out.println();
        System.out.println("Product Number: ");
        prodNo = in.nextLong();
        System.out.println("Product Quantity: ");
        qty = in.nextInt();
        System.out.println("------------------------");
        System.out.println("Enter Another Item (Y/N): ");
        System.out.println("------------------------");
        yesNo = in.next().charAt(0);

        //generate sale line item number
        int line = si.getSaleLine() + 1;

        //get product name from
        name = prodL.getProdName((int)prodNo - 1);



        ***//get product price from inventory_list
        THIS IS THE PART I DON'T KNOW HOW TO GET***




        //create sale item object
        si = new saleItem();
        si.setSaleNo(saleNo);
        si.setSaleLine(line);
        si.setProdNo(prodNo);
        si.setProdName(name);
        si.setQuantity(qty);
        si.setProdPrice(price);

        //insert sale_item set
        saleIS.insert(si);

感谢您的帮助。

0 个答案:

没有答案