Please help me..I need to fix my array. This is from my instructor..Your program compiled and ran well. It implemented all of the requirements for the assignment. You have a separate class that stores your Product, and your products are stored in arrays. You also implemented methods to sort the array and to calculate the entire inventory value. However, upon completion of the program, it does not display the product information sorted by the product name or the inventory value. The reason is that your array is initialized to a size of 0. An array cannot be dynamically resized. You must either prompt the user to enter the number of Cameras to be entered, or you must initialize the array to a rather large size. It does not need to be completely filled in.

//Inventory.java 

//Program that displays the value of cameras.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Locale;

// class that represents a camera in inventory
class Camera implements Comparable<Object> {
	private double itemnum;
	private double cameraprice;
	private double numinstock;
	static String cameraname;
	private String deptname;

	public Camera(int theItemNumber, double theCameraPrice,
			int theNumberInStock, String theCameraName) // constructor
	{
		itemnum = 0.0;
		cameraprice = 0.0;
		numinstock = 0.0;
	}

	public void setItemNum(double num) // set item number
	{
		itemnum = num;
	}

	public double getitemnumber() // get item number
	{
		return itemnum;
	}

	public void setcameraprice(double camera) // set price
	{
		cameraprice = camera;
	}

	public double getcameraprice() // get price
	{
		return cameraprice;
	}

	public void setnuminstock(double numstock) // set number in stock
	{
		numinstock = numstock;
	}

	public double getnuminstock() // get number in stock
	{
		return numinstock;
	}

	public void setdptname(String department) // set department name
	{
		deptname = department;
	}

	public String getdeptname() // get department name
	{
		return deptname;
	}

	public void setcameraname(String name) // set camera name
	{
		setCameraname(name);
	}

	public String getcameraname() // get camera name
	{
		return getCameraname();
	}

	public double calculateValue() // calculate the value
	{
		return cameraprice * numinstock;
	}

	@Override
	public int compareTo(Object o) {
		Camera p = (Camera) o;
		return getCameraname().compareTo(p.getcameraname());
	}

	// returns a string representation of the product
	@Override
	public String toString() {
		return "Department Name    : "
				+ getdeptname()
				+ "\n"
				+ "Camera Name    : "
				+ getcameraname()
				+ "\n"
				+ "Camera Number  : "
				+ getitemnumber()
				+ "\n"
				+ "Camera Price   : "
				+ NumberFormat.getCurrencyInstance(Locale.US).format(
						getcameraprice())
				+ "\n"
				+ "Number in Stock : "
				+ getnuminstock()
				+ "\n"
				+ "Value           : "
				+ NumberFormat.getCurrencyInstance(Locale.US).format(
						calculateValue());
	}

	public void setCameraname(String cameraname) {
		Camera.cameraname = cameraname;
	}

	public static String getCameraname() {
		return cameraname;
	}

}// end class Camera

class DigitalCamera extends Camera {

	// image resolution of the digital camera added
	public static String imageResolution;

	// restocking fee
	private static double restockingFee;

	public DigitalCamera() {

		super(0, restockingFee, 0, imageResolution);

		// the default restocking fee is 5%
		restockingFee = 0.05;
	}

	// initialize an OfficeSupply object with the given information
	public DigitalCamera(int theItemNumber, double theCameraPrice,
			int theNumberInStock, String theCameraName,
			String theImageResolution) {

		// call the Product constructor
		super(theItemNumber, theCameraPrice, theNumberInStock, theCameraName);

		// and fill in the extra details about an OfficeSupply
		imageResolution = theImageResolution;
		// the default restocking fee is 5%
		restockingFee = 0.05;
	}

	public static void setResolution(String theImageResolution) {
		imageResolution = theImageResolution;
	}

	public String getResolution() { // get resolution
		return imageResolution;
	}

	public double getRestockingFee() // get restocking fee
	{
		return super.calculateValue() * restockingFee;
	}

	// include a restocking fee in the inventory's value
	@Override
	public double calculateValue() // calculates total inventory value including
									// restocking fee
	{
		return super.calculateValue() + getRestockingFee();
	}

	@Override
	public String toString() {
		return "Department Name    : "
				+ getdeptname()
				+ "\n"
				+ "Camera Name    : "
				+ getcameraname()
				+ "\n"
				+ "Image Resolution    : "
				+ getResolution()
				+ "\n"
				+ "Camera Number  : "
				+ getitemnumber()
				+ "\n"
				+ "Camera Price   : "
				+ NumberFormat.getCurrencyInstance(Locale.US).format(
						getcameraprice())
				+ "\n"
				+ "Number in Stock : "
				+ getnuminstock()
				+ "\n"
				+ "Restocking Fee  : "
				+ NumberFormat.getCurrencyInstance(Locale.US).format(
						getRestockingFee())
				+ "\n"
				+ "Value           : "
				+ NumberFormat.getCurrencyInstance(Locale.US).format(
						calculateValue());
	}

} // end class digital camera

// class inventory
class Inventory {

	static Camera[] inventory;

	public Inventory() {
		inventory = new Camera[0];
	}

	public static void addCamera(Camera new_Camera) {

		Camera[] new_inventory = new Camera[getSize() + 1];

		// old array to the front of the new array
		for (int i = 0; i < getSize(); i++) {
			new_inventory[i] = inventory[i];
		}

		// new camera to the end of the new array
		new_inventory[getSize()] = new_Camera;

		// replace the old inventory with the new one
		inventory = new_inventory;

	}

	// return the cameras at the index in the inventory
	public static Camera getCamera(int index) {
		return inventory[index];
	}

	// return the number of cameras in the inventory
	public static int getSize() {
		return inventory.length;
	}

	// add up inventory value.
	public static double getTotalValueOfAllInventory() {
		double tot = 0.00;

		for (int i = 0; i < getSize(); i++) {
			tot += inventory[i].calculateValue();
		}
		return tot;
	}

	// sort the cameras
	public static void sortInventory() {
		Arrays.sort(inventory, 0, getSize());
	}

}

// program that displays the value of a camera in inventory.
public class Inventory2

{
	public static void main(String args[]) throws IOException {

		boolean stop = false;

		while (!stop) {

			// create scanner
			BufferedReader input = new BufferedReader(new InputStreamReader(
					System.in));

			new Inventory();
			Camera cameraItem = new DigitalCamera();

			// welcome screen
			System.out.println("\nWelcome to the Inventory Program\n");

			System.out
					.print("Please enter the name of the Camera or the word Stop:"); // prompt
			// for
			// user
			// input

			cameraItem.setcameraname(input.readLine());// read camera item name
														// or stop

			// if stop is entered for the item name, then terminate program
			if (Camera.getCameraname().compareTo("stop") == 0) {
				System.out
						.println("Thank you, the Inventory Program will now terminate");
				stop = true;

			} else if ("name" != Camera.cameraname) {

				System.out.print("Please enter the Department Name:"); // prompt
																		// for
																		// user
																		// input
				cameraItem.setdptname(input.readLine()); // for

				System.out.print("Please enter the Camera Item Number:"); // prompt
																			// for
																			// user
																			// input

				double d = Double.valueOf(input.readLine()).doubleValue();
				cameraItem.setItemNum(d);// read item number

				while (cameraItem.getitemnumber() <= 0.0) {
					System.out.println("Invalid Entry");
					System.out
							.println("Please enter a positive Camera Item Number:");
					cameraItem.setItemNum(Double.valueOf(input.readLine())
							.doubleValue()); // read Item number
				}
				System.out.print("Please enter the Camera's Image Resolution:");
				DigitalCamera.setResolution(input.readLine());

				System.out.print("Please enter number of Cameras in Stock:");
				cameraItem.setnuminstock(Double.valueOf(input.readLine())
						.doubleValue()); // read
				// number of camera items in stock

				while (cameraItem.getnuminstock() <= 0.0) {
					System.out.println("Invalid Entry");
					System.out
							.println("Please enter a positive number for Cameras in Stock:");
					cameraItem.setnuminstock(Double.valueOf(input.readLine())
							.doubleValue()); // read Item number
				}

				System.out.print("Please enter the price of the Camera: "); // prompt
																			// for
																			// input
				cameraItem.setcameraprice(Double.valueOf(input.readLine())
						.doubleValue()); // read camera price

				while (cameraItem.getcameraprice() <= 0.0) {
					System.out.println("Invalid Entry");
					System.out.println("Please enter a positive Camera price:");
					cameraItem.setcameraprice(Double.valueOf(input.readLine())
							.doubleValue()); // read camera Price
				}

				// add the newly created object to inventory
				Inventory.addCamera(cameraItem);

			} // end while

			Inventory.sortInventory();

			// display the inventory of cameras on the screen, one camera at a
			// time
			for (int i = 0; i < Inventory.getSize(); i++) {
				System.out.println(Inventory.getCamera(i)); // returns the
				// product at location i
				System.out.println();
			}

			// display the total value of the inventory on the screen
			System.out.println("The Total Value of the inventory is: "
					+ NumberFormat.getCurrencyInstance(Locale.US).format(
							Inventory.getTotalValueOfAllInventory()));

		} // end method main

	}
} // end class Inventory2

Recommended Answers

All 4 Replies

Okay? So what's your question?

Or you can use an ArrayList and convert it to an array..

What your instructor means is that here:

class Inventory {

	static Camera[] inventory;

	public Inventory() {
		inventory = new Camera[0];
	}

you declare the array "inventory" to have zero members. That is, it's an empty set: it's an array of no cameras.

Since an array's size cannot be changed, this is not very useful to you. Your instructor is suggesting that you either find out how many cameras your user wishes to deal with and declare an array of that size:

/// get a number n from the user somehow
inventory = new Camera[n];

or else declare an array of a size you hope is big enough that the user won't fill it:

int n = ONE BAZILLION!!!!; //or some other large number
inventory = new Camera[n];

Either of those would, apparently, allow you to handle your output correctly - I haven't read the rest of your code, but I'll assume your instructor knows what he's talking about.

Hope this helps.

Thank you for the last response. I have another problem.. on line marked as (HELP LINE) I receive the message identifier expected? I am not sure exactly what I need to insert to fix it so that it will compile.

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.text.JTextComponent;

public class InventoryPart5 {

    private static final String EXIT_ON_CLOSE = null;

    // main method begins program execution
    public static <Inventory> void main(String args[]) throws IOException {

        // create scanner
        BufferedReader input = new BufferedReader(new InputStreamReader(
                System.in));


        // Instantiate a GUI Inventory object
        InventoryGUI InventoryGUI = new InventoryGUI();

        // change this to false to do command line input
        if (true) {

            InventoryGUI.addCameraToInventory(new camera(7463, "Kodak", 10,
                    32.00, "Electronics", "1200 x 800"));
            InventoryGUI.addCameraToInventory(new camera(5642, "Olympus", 5,
                    25.00, "Electronics", "640 x 480"));
            InventoryGUI.addCameraToInventory(new camera(3541, "Panasonic", 20,
                    100.00, "Electronics", "1500 x 1200"));
            InventoryGUI.addCameraToInventory(new camera(4049, "Canon", 30,
                    50.00, "Electronics", "1200 x 800"));

        } else {
            // display a welcome message to the Inventory Program
            System.out.println("Welcome to the Inventory Program ");

            // camera

            camera kodak = new camera(2563, "Kodak", 45, 65.80, "Electronics",
                    "640 x 480");
            camera canon = new camera(5000, "Canon", 32, 95.99, "Electronics",
                    "1200 x 800");
            camera olympus = new camera(1157, "Olympus", 96, 86.99,
                    "Electronics", "1500 x 1200");
            camera panasonic = new camera(3976, "Panasonic", 27, 72.95,
                    "Electronics", "640 x 480");
            camera nikon = new camera(3241, "Nikon", 68, 106.99, "Electronics",
                    "1500 x 1200");

            // display the camera inventories one at a time
            kodak.showInventory();
            canon.showInventory();
            olympus.showInventory();
            panasonic.showInventory();
            nikon.showInventory();

            // sort cameras by name
            for (String arg : args) {
                System.out.println(arg + ", ");
            }

            double array[] = { 2961.00, 3071.68, 8351.04, 1969.65, 7275.32 };
            double total = 0;

            // add each element's value to total
            for (double element : array) {
                total += element;
            }
            System.out.printf("\nTotal inventory value is: $%.2f\n", total);

            System.out.println("\nThank you for using the Inventory Program\n");

            InventoryGUI.sortInventory();



        } // end method main

    } // end class Inventory Part 5

    @SuppressWarnings("rawtypes")
    // camera
    class camera implements Comparable {
        public String deptName;
        public String cameraName = new String();
        public int cameraNumber;
        public int cameraUnits;
        public double cameraPrice;
        public String imageResolution;

        // set camera number
        public void setCameraNumber(int number) {
            cameraNumber = number;
        } // end method set camera number

        // return camera number
        public int getCameraNumber() {
            return cameraNumber;
        } // end method get camera number

        // set camera name
        public void setCameraName(String name) {
            cameraName = name;
        } // end method set camera name

        // return camera name
        public String getCameraName() {
            return cameraName;
        } // end method get camera name

        // set camera units in stock
        public void setCameraUnits(int units) {
            cameraUnits = units;
        } // end method set camera units in stock

        // return camera units in stock
        public int getCameraUnits() {
            return cameraUnits;
        } // end method get camera units in stock

        // set camera price
        public void setCameraPrice(double price) {
            cameraPrice = price;
        } // end method set camera price

        // return camera price
        public double getCameraPrice() {
            return cameraPrice;

        } // end method get camera price

        public double getRestockingFee() {
            return .05;
        }

        public String getImageResolution() {
            return null;
        }

        // calculate camera inventory value
        public double getValue() {
            return cameraUnits * cameraPrice;
        } // end method camera inventory value

        // five-argument constructor
        camera(int number, String name, int units, double price,
                String department, String resolution) {
            deptName = department;
            cameraNumber = number;
            cameraName = name;
            imageResolution = resolution;
            cameraUnits = units;
            cameraPrice = price;
        }

        public camera(int i, double d, int j, String string, String string2) {

        }

        // end five-argument constructor

        // display inventory
        public void showInventory() {
            System.out.println(); // outputs blank line

            System.out.println("Department Name;: " + deptName);
            System.out.println("Camera Number:  " + cameraNumber);
            System.out.println("Camera Name:  " + cameraName);
            System.out.println("Image Resolution: " + imageResolution);
            System.out.println("Units in Stock:  " + cameraUnits);
            System.out.printf("Unit Price:  $%.2f\n", cameraPrice);
            System.out.printf("Restocking Fee: $%.2f", cameraPrice * .05);

            new digital(4000, "Panasonic", 60, 32.00, "Electronics");

            // value() method and display the value
            System.out.printf("\nInventory value of " + cameraName
                    + " is = $%.2f\n", getValue() * 1.05);

        } // end display inventory

        @Override
        public int compareTo(Object arg0) {

            return 0;
        }

    } // end class camera

    class digital extends camera {
        // holds the digital cameras
        private static String imageResolution;

        // five-argument constructor
        digital(int number, String name, int units, double price, String digital) {

            super(number, name, units, price, digital, imageResolution);
            cameraName = digital;
        }

        // set camera digital
        public void setDigital(String digital) {
            String resolution = imageResolution;
            imageResolution = resolution;
        } // end method set camera digital

        // return camera digital {
        public String getDigitalCamera() {
            return imageResolution;
        } // end method get camera digital

        // add 5% restocking fee
        @Override
        public double getValue() {
            return super.getValue() * 1.05;
        } // end method return camera digital

        // calculate restocking fee
        @Override
        public double getRestockingFee() {
            return super.getValue() * .05;
        } // end method calculate restocking fee

        // return String representation of digital camera
        @Override
        public String toString() {
            String formatString = "Digital:  %s";
            formatString += "Restocking Fee:  $%.2f";
            formatString = imageResolution;
            formatString = String.format(formatString, formatString,
                    super.getValue() * 0.05);
            return formatString + super.toString();
        } // end toString()

        // display inventory
        @Override
        public void showInventory() {
            super.showInventory();
            System.out.println(toString());

            // Display value plus restocking fee
            System.out.printf("\nInventory value of " + cameraName
                    + " is = $%.2f\n", getRestockingFee());

        } // end method display inventory

    } // end class digital

    class InventoryGUI extends JFrame {

        public Object InventoryGUI;

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        // create inventory for cameras
        private final InventoryGUI Inventory;

        private final int index = 0;

        // GUI elements to display currently selected camera information
        private final JLabel cameraNumberLabel = new JLabel("Camera Number: ");
        private final JTextField cameraNumberText;
        private final JLabel cameranameLabel = new JLabel("Camera Name: ");
        private final JTextField cameraNameText;
        private final JLabel imageresolutionLabel = new JLabel(
                "Image Resolution: ");
        private final JTextField imageresolutionText;
        private final JLabel camerapriceLabel = new JLabel("Camera Price: ");
        private final JTextField camerapriceText;
        private final JLabel cameraunitsLabel = new JLabel(
                "Number of units in Stock: ");
        private final JTextField cameraunitsText;
        private final JLabel valueLabel = new JLabel("Value: ");
        private final JTextField valueText;
        private final JLabel restockingFeeLabel = new JLabel("Restocking Fee: ");
        private final JTextField restockingFeeText;
        private final JLabel totalValueLabel = new JLabel(
                "Inventory Total Value: ");
        private final JLabel totalValueText;

        protected int camera;

        // go to the next camera in the list
        private final Action nextAction = new AbstractAction("Next") {
            /**
             * 
             */
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent evt) {
                // go forward one product
                index++;

                // check to see if there is a next product
                if (index == Inventory()) {
                    index--;
                }

                repaint();
            }
            InventoryPart5.showInventoryGUI();  (HELP LINE)         

        };
        private final JButton nextButton = new JButton(nextAction);

        // go the previous product in the list
        private final Action previousAction = new AbstractAction("Previous") {

            /**
             * 
             */
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent evt) {
                index--;
                // if the user hits previous at the first product in the list,
                // then
                // loop back to the last product
                if (index ==(0)) {
                    index--;
                }
                repaint();
            }

        };
        private final JButton previousButton = new JButton(previousAction);
        // advance to the first product in the list
        private final Action firstAction = new AbstractAction("First") {
            /**
             * 
             */
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent evt) {
                index = 0;
                repaint();

            }

        };
        private final JButton firstButton = new JButton(firstAction);
        // advance to the last product in the list
        private final Action lastAction = new AbstractAction("Last") {
            /**
             * 
             */
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent evt) {
                index--;
                // if the user hits previous at the first product in the list,
                // then
                // loop back to the last product
                if (index < 0) {
                    index = getShowInventory(-1);
                }
                repaint();
            }
        };
        private final JButton lastButton = new JButton(lastAction);

        // Add the product to the underlying inventory object
        public void addCameraToInventory(camera temp) {
            Inventory.addCamera(temp);
            sortInventory();
            repaint();
        }



        protected int Inventory() {

            return 0;
        }

        private void addCamera(InventoryPart5.camera temp) {


        }

        public void sortInventory() {


        }

        public camera getShowInventory(Object index2) {

            return null;
        }

        public Object getTotalValueOfAllInventory() {

            return null;
        }

    }

    public Object getTotalValueOfAllInventory() {

        return null;
    }

    private static InventoryPart5.InventoryGUI Inventory;

    // sort the cameras in the inventory
    public void sortInventory() {
        Inventory.sortInventory();
        repaint();
    }

    // constructor
    @SuppressWarnings("null")
    public void InventoryGUI() {
        new InventoryPart5();

        JPanel buttonPanel = new JPanel(new GridLayout(1, 4, 0, 4));
        Component firstButton = null;
        buttonPanel.add(firstButton);
        Component previousButton = null;
        buttonPanel.add(previousButton);
        Component nextButton = null;
        buttonPanel.add(nextButton);
        Component lastButton = null;
        buttonPanel.add(lastButton);
        getContentPane().add(buttonPanel, BorderLayout.SOUTH);

        // camera information
        // setup a panel
        JPanel centerPanel = new JPanel(new GridLayout(10, 4, 0, 8));

        Component cameraNumberLabel = null;
        centerPanel.add(cameraNumberLabel);
        ((JComponent) cameraNumberLabel).setBorder(BorderFactory
                .createEmptyBorder(0, 4, 0, 4));
        JTextField cameranumberText = new JTextField("");
        cameranumberText.setEditable(false);
        centerPanel.add(cameranumberText);

        Component cameranameLabel = null;
        centerPanel.add(cameranameLabel);
        ((JComponent) cameranameLabel).setBorder(BorderFactory
                .createEmptyBorder(0, 4, 0, 4));
        JTextField cameranameText = new JTextField("");
        cameranameText.setEditable(false);
        centerPanel.add(cameranameText);

        Component imageresolutionLabel = null;
        centerPanel.add(imageresolutionLabel);
        ((JComponent) imageresolutionLabel).setBorder(BorderFactory
                .createEmptyBorder(0, 4, 0, 4));
        JTextField imageresolutionText = new JTextField("");
        imageresolutionText.setEditable(false);
        centerPanel.add(imageresolutionText);

        Component camerapriceLabel = null;
        centerPanel.add(camerapriceLabel);
        ((JComponent) camerapriceLabel).setBorder(BorderFactory
                .createEmptyBorder(0, 4, 0, 4));
        JTextField camerapriceText = new JTextField("");
        camerapriceText.setEditable(false);
        centerPanel.add(camerapriceText);

        Component cameraunitsLabel = null;
        centerPanel.add(cameraunitsLabel);
        ((JComponent) cameraunitsLabel).setBorder(BorderFactory
                .createEmptyBorder(0, 4, 0, 4));
        JTextField cameraunitsText = new JTextField("");
        cameraunitsText.setEditable(false);
        centerPanel.add(cameraunitsText);

        Component restockingFeeLabel = null;
        centerPanel.add(restockingFeeLabel);
        ((JComponent) restockingFeeLabel).setBorder(BorderFactory
                .createEmptyBorder(0, 4, 0, 4));
        Component restockingFeeText = new JTextField("");
        ((JTextComponent) restockingFeeText).setEditable(false);
        centerPanel.add(restockingFeeText);

        Component valueLabel = null;
        centerPanel.add(valueLabel);
        ((JComponent) valueLabel).setBorder(BorderFactory.createEmptyBorder(0,
                4, 0, 4));
        Component valueText = new JTextField("");
        ((JTextComponent) valueText).setEditable(false);
        centerPanel.add(valueText);

        Component totalValueLabel = null;
        // add the overall inventory information panel
        centerPanel.add(totalValueLabel);
        JLabel totalValueText = new JLabel("");
        centerPanel.add(totalValueText);

        // setup the logo for the GUI
        URL url = this.getClass().getResource("logo.jpg");
        Image img = Toolkit.getDefaultToolkit().getImage(url);

        // scale the image so that it'll fit in the GUI
        Image scaledImage = img.getScaledInstance(205, 300,
                Image.SCALE_AREA_AVERAGING);

        // create a JLabel with the image as the label's Icon
        Icon logoIcon = new ImageIcon(scaledImage);
        JLabel companyLogoLabel = new JLabel(logoIcon);
        companyLogoLabel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));

        // add the logo to the GUI
        getContentPane().add(companyLogoLabel, BorderLayout.WEST);

        // add the panel to the center of the GUI's window
        getContentPane().add(centerPanel, BorderLayout.CENTER);

    }

    private Container getContentPane() {

        return null;
    }

    // Get the GUI to show up on the screen
    public void showGUI() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        pack();
        setSize(700, 350);
        setResizable(false);
        setLocationRelativeTo(null);
        setVisible(true);

        repaint();
    }

    private void setVisible(boolean b) {

    }

    private void setLocationRelativeTo(Object object) {

    }

    private void setResizable(boolean b) {

    }

    private void setSize(int i, int j) {

    }

    private void pack() {

    }

    private void setDefaultCloseOperation(String exitOnClose) {

    }

    // repaint the GUI with current camera information
    @SuppressWarnings("null")
    public void repaint() {

        Object index = null;
        camera temp = Inventory.getShowInventory(index);

        if (temp != null) {

            AbstractButton cameraNumberText = null;
            cameraNumberText.setText("" + temp.getCameraNumber());

            AbstractButton cameranameText = null;
            cameranameText.setText(temp.getCameraName());
            AbstractButton imageresolutionText = null;
            imageresolutionText.setText(temp.getImageResolution());
            AbstractButton camerapriceText = null;
            camerapriceText.setText(String.format("$%.2f",
                    temp.getCameraPrice()));
            AbstractButton restockingFeeText = null;
            restockingFeeText.setText(String.format("$%.2f",
                    temp.getRestockingFee()));
            AbstractButton cameraunitsText = null;
            cameraunitsText.setText("" + temp.getCameraUnits());

            AbstractButton valueText = null;
            valueText.setText(String.format("$%.2f", temp.getValue()));

        }

        AbstractButton totalValueText = null;
        totalValueText.setText(String.format("$%.2f",
                Inventory.getTotalValueOfAllInventory()));

    }

} // End InventoryGUI class
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.