Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Cannot find symbol - method getItemNumber()

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Cannot find symbol - method getItemNumber()

    String line;
    for (int i = 0; i < products.size(); i++) {

    Supplier product = products.get(i);

    line = product.getProductName() + "\t";
    line += product.getItemNumber() + "\t";
    line += product.getPrice() + "\t";
    line += product.getUnitsInStock() + "\t";
    line += product.getSupplierName() + "\n";

    try {
    writer.write(line);
    } catch (IOException e) {
    JOptionPane.showMessageDialog(null,
    "Could not write in the inventory file.");
    }
    }

    --- Update ---

    this is the Supplier class

    public class Supplier extends Inventary {

    /**
    * Supplier Name
    */

    private String supplierName;

    /**
    * Default constructor;
    */
    public Supplier() {
    }

    /**
    * Constructor should have 5 parameters:
    *
    * - Item Number
    *
    * - Product Name
    *
    * - Number of Units in Stock
    *
    * - Price of each Unit
    *
    * - Supplier Name
    */
    public Supplier(int itemNumber, String productName, int unitsInStock,
    double price, String supplierName) {
    /*
    * Note you will use the super keyword to invoke the constructor in your
    * Product class.
    */
    // super(itemNumber, productName, unitsInStock, price);

    this.itemNumber = itemNumber;
    this.productName = productName;
    this.unitsInStock = unitsInStock;
    this.price = price;
    this.supplierName = supplierName;
    }

    /**
    * return the product name
    */

    public String getProductName(){

    return productName;


    }

    /**
    * return the unitsInStock
    */

    public int getUnitsInStock(){

    return unitsInStock;

    }

    /**
    * return the price.
    */

    public double getprice(){

    return price;

    }

    /**
    * @return the supplierName
    */
    public String getSupplierName() {
    return supplierName;
    }

    /**
    * need to set the itemNumber.
    */

    public void setItemNumber( int itemNumber ) {

    this.itemNumber = itemNumber;

    }

    /**
    * product name to set
    */

    public void setName ( String productName ) {

    this.productName = productName;

    }

    /**
    * price to set
    */

    public void setPrice ( double price ) {

    this.price = price;

    }

    /**
    * @param supplierName
    * the supplierName to set
    */
    public void setSupplierName(String supplierName) {
    this.supplierName = supplierName;
    }


    /**
    * This method returns the product of price and available units multiplied
    * by 5% ((price * product) * .05);
    */
    public double calculateRestockFee() {

    return calculateInventory() * .05;

    }

    /**
    * This method returns the product of price and available units plus the
    * restock fee.
    */
    public double calculateInventory() {
    return calculateInventory() + calculateRestockFee();
    }



    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Cannot find symbol - method getItemNumber()

    First of all, when posting code, make sure you use the highlight tags to preserve formatting. Unformatted code is pretty hard to read. Secondly, code you post should be in the form of an SSCCE. We can't see what kinds of functions are defined in Supplier's super class (Inventary?), so we can't really help you other than to tell you that the error means the compiler can't find a function you're trying to use.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Member
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    54
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Default Re: Cannot find symbol - method getItemNumber()

    Your Supplier class does not have the method getItemNumber().

Similar Threads

  1. Cannot find symbol method getPrice()?
    By EDale in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 30th, 2013, 02:41 PM
  2. Remaining compile errors: no suitable method found for & cannot find symbol
    By ChuckLep in forum What's Wrong With My Code?
    Replies: 4
    Last Post: December 12th, 2011, 03:33 PM
  3. [SOLVED] Cannot find symbol - Calling method passing array Pets
    By Rilstin81 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 11th, 2011, 03:27 PM
  4. Using Queue, cannot find symbol method enqueue
    By firebluetom in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 17th, 2011, 01:41 PM
  5. cannot find symbol - method
    By kyuss in forum Object Oriented Programming
    Replies: 2
    Last Post: December 7th, 2009, 01:01 PM

Tags for this Thread