I cannot figure out how to get my icon to display, or get the GUI to flip through my array object. i have many errors that i cannot solve. i hope some one can help me. here is my code.

import javax.swing.JFrame;//imports java's JFrame component
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
//Main Class Inventory
public class Inventory extends JFrame//extends the JFrame component
{//001
//-----------------------------------------------------------------------------------------------------------
// The main class declartion with the method that implaments the GUI class of the inventory program
//-----------------------------------------------------------------------------------------------------------
    public static void main(String args[])//Declaration of main method. Makes the class Inventory the application class
    {//002
        InventoryInterface Interface = new InventoryInterface();
        Interface.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Interface.setSize(320,300);
        Interface.setVisible(true);
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
    }//002
}//001
import javax.swing.JTextField;

//-----------------------------------------------------------------------------------------------------------
// This class has been created for the purpose of contorling the out put of the Digital Camera object.
// This class also performs calculations for the return of the total value of the inventory.
//-----------------------------------------------------------------------------------------------------------

public class Methods extends DigitalCamera
{//001

    
    int counter = 0;//stores the counter value, and set it to start at the zero object of the array
    int Last;//stores the last as a result from methods perform in teh set method, and is also use to return in the get method. that is the methods that use this variable
    DigitalCamera[] myDigitalCamera = new DigitalCamera[counter];//Creates DigitalCamera array object with getArrayNumber for creating new objects

    int ArrayNumber;//stores the arrayNumber from the counter value
//-----------------------------------------------------------------------------------------------------------
// Constructor for the Methods class
//-----------------------------------------------------------------------------------------------------------
 Methods()
    {//002
        myDigitalCamera[0] = new DigitalCamera(1001,"A",20,100.89,5.8);//Defines the DigitalCamera object
        myDigitalCamera[1] = new DigitalCamera(1002,"B",10,389.78,9.7);//Defines the DigitalCamera object
        myDigitalCamera[2] = new DigitalCamera(1003,"C",15,235.58,5.5);//Defines the DigitalCamera object
        myDigitalCamera[3] = new DigitalCamera(1004,"D",2,545.91,10.2);//Defines the DigitalCamera object
        myDigitalCamera[4] = new DigitalCamera(1005,"E",50,45.21,4.5);//Defines the DigitalCamera object
    }//002


//-----------------------------------------------------------------------------------------------------------
// Collection of methods that allow GUI navagation through the Digital Camera inventory
//-----------------------------------------------------------------------------------------------------------

    public int getNext()
    {//003
        return counter++;
    }//003
//============================
    public int getPrivious()
    {//004
       return counter--;
    }//004
//============================
    public int getFirst()
    {//005
        return counter = 0;
    }//005
//============================
    public int getLast()
    {//006
        return Last;
    }//006
//============================
    public int getCounter()
    {//009
        return counter;
    }//009
//-----------------------------------------------------------------------------------------------------------
// Collection of Methods for setting the inventorys total cost
//-----------------------------------------------------------------------------------------------------------
    public void setTotalCost(double C)//Method for calculating the total cost of inventroy
    {//010
        for (counter = 0; counter < getCounter(); counter++)//cycles through the digital camera array
        {//011
            double Q;
            double Q1;
            Q = myDigitalCamera[getCounter()].getQTY() * myDigitalCamera[getCounter()].getUnitCost();
        }//011
    }//010
//============================================================================================================
    public double getTotalCost(double C)//Method for calling the total cost of inventroyx
    {//012
        return C;
    }//012
//-----------------------------------------------------------------------------------------------------------
// Colection of set methods for user input
//-----------------------------------------------------------------------------------------------------------
    @Override
    public void setUPC(int UPC)
    {
        UPC = myDigitalCamera[getCounter()].UPC;
    }
//================================================
    @Override
    public void setDescription(String Name)
    {
        Name = myDigitalCamera[getCounter()].Name;
    }
//================================================
    @Override
    public void setQTY(int QTY)
    {
        QTY = myDigitalCamera[getCounter()].QTY;
    }
//================================================
    @Override
    public void setCost(double Cost)
    {
        Cost = myDigitalCamera[getCounter()].Cost;
    }
//================================================
    @Override
    public void setRes(double ImageResolution)
    {
        ImageResolution = myDigitalCamera[getCounter()].ImageResolution;
    }

}//001
//Camera class
public class Camera
{//001
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
    //Stores data
    private int UPC;
    private String Name;
    private int QTY;
    private double UnitCost;
    private double TotalItemCost;
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
    //Empty Constrcutor. Does nothing.
    Camera()
    {

    }
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
    //Camera constructor stores camera data, and creates a way to pass the data to another class.
    Camera(int PartNumber, String Description, int Quantity, double CostPerUnit)
    {
        UPC = PartNumber;//stores UPC of the camera
        Name = Description;//stores Description of the camera
        QTY = Quantity;//stores the quantity of the camera
        UnitCost = CostPerUnit;//stores the unit cost
    }
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------

    //Method for setting the total cost of one camera item
    public void setCostOfInventory(double TotalItemCost)
    {
           TotalItemCost = UnitCost * QTY;//calcualates the total for one camera type
    }

    //Method to return the total item cost
    public  double getCostOfInventory()
    {
        return TotalItemCost;//returns the total item cost when the method is called
    }

    //Method for returning the UPC number of a camera item
    public int getUPC()
    {
        return UPC;//returns the UPC number when the method is called
    }

    //Method for returning the name of a camera item
    public String getName()
    {
        return Name;//returns the name of a camera when the method is called
    }

    //Mehod for returning the quantity of a camera item
    public int getQTY()
    {
        return QTY;//retruns the quantity of a camera item when the method is called
    }

    //Method for returning the unit cost of a camera item
    public double getUnitCost()
    {
        return UnitCost;//returns the unit cost of a camera item when the method is called
    }
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
}
//DigitalCamera class extends the Camera class and adds resolution
public class DigitalCamera extends Camera
{//001
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
    public double ImageResolution;//Variable for storing the resolution of a camera
    public int UPC;
    public String Name;
    public int QTY;
    public double Cost;
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
    //Empty Construct. This construct does nothing.
    DigitalCamera()
    {//002

    }//002
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
    //This is the public Constructor of DigitalCamera. This construct serves the purpose of calling class
    //Camera constructor, and adding the resolution element. The purpose of this is so that we can store
    //data in the camera class along with the new element decalered here in the digitalCamera class.
    public DigitalCamera(int PartNumber, String Description, int Quantity, double CostPerUnit,double Resolution)
    {//003
        super(PartNumber,Description,Quantity,CostPerUnit);//invokes the Camera class's constructor
        ImageResolution = Resolution;//stores the resolution data
    }//003
//-----------------------------------------------------------------------------------------------------------
// Collection of get methods
//-----------------------------------------------------------------------------------------------------------
    //method for reuturning the resolution
    public double getImageResolution()
    {//004
        return ImageResolution;//returns the resolution of a camera item when the method is called
    }//004

    @Override
    public int getUPC()
    {
        return UPC;
    }

    @Override
    public String getName()
    {
        return Name;
    }

    @Override
    public int getQTY()
    {
        return QTY;
    }

    public double getCost()
    {
        return Cost;
    }
//-----------------------------------------------------------------------------------------------------------
// Collection of set methods
//-----------------------------------------------------------------------------------------------------------

    public void setUPC(int PartNumber)
    {
        UPC = PartNumber;
    }

    public void setDescription(String Description)
    {
        Name = Description;
    }

    public void setQTY(int Quantity)
    {
        QTY = Quantity;
    }

    public void setCost(double CostPerUnit)
    {
        Cost = CostPerUnit;
    }

    public void setRes(double Resolution)
    {
        ImageResolution = Resolution;
    }
}//001

Recommended Answers

All 2 Replies

Three things to do immediately:

  1. Use code-tags as described in the 'readme first' threads
  2. Remove about 75% of the code from your post, leaving enough to show the problem
  3. Be quite specific about what the problem(s) is/are: Cut and paste the error messages.

And a forth thing to help you code: Start with a small bit of code. Get it working ("hello window" or the like). Add one thing at a time, making sure that it still works after each addition. If it fails, immediately stop adding things and fix the problem before you go on.

Something to consider: If your data members are public, why do you need setters and getters? (Hint: Think about whether they should be public.)

i have many errors that i cannot solve

See 3. above.
We can't help you without the full text of the error messages you are getting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.