I am having problems getting my program to compile and run. Newbie from the word go. The main problem is I have all of the code but I cannot make the other classes go with the main class. Any help would be great.
Here is the code that I have and it only returns the movies class

public class Movies {



    /**
     * @param args
     *///main method
    public static void main(String args[]) {

        new Movies();

        // This program will track DVD movies with number in stock, name of DVD,
        // price of Dvd and the total value of inventory

        /**
         * Constructor for objects of class GBInventory
         */

        {
            new java.util.Scanner(System.in);

            DVD[] dvd = new DVD[4];

            dvd[0] = new DVD("Undercover Blues", 4, 19.99, 1025);
            dvd[1] = new DVD("Die Hard", 8, 19.98, 146);
            dvd[2] = new DVD("Shrek", 10, 19.99, 434);
            dvd[3] = new DVD("That Old Feeling", 8, 18.56, 995);

            for (int i = 0; i < 4; i++) {

                System.out.println("Product Title is " + dvd[i].getDvdTitle());
                System.out.println();
                System.out.println("The number of units in stock is "
                        + dvd[i].getDvdStock());
                System.out.println("The price of each DVD is "
                        + dvd[i].getDvdPrice());
                System.out.println("The item number is " + dvd[i].getDvdItem());
                System.out.println("The value of the inventory is "
                        + dvd[i].value());
                System.out.println();

            }

        }

    } // end method main

    class DVDMovies {

        private String dvdTitle;
        private double dvdStock;
        private double dvdPrice;
        private double dvdItem;

        DVDMovies(String title, double stock, double price, double item) {
            dvdTitle = title;
            dvdStock = stock;
            dvdPrice = price;
            dvdItem = item;
        } // end constructor

        public void setDvdTitle(String title) {
            dvdTitle = title;
        } // end method setDvdTitle

        // return DVD Title
        public String getDvdTitle() {
            return dvdTitle;
        } // end method getDvdTitle

        // set DVD Stock
        public void setDvdStock(double stock) {
            dvdStock = stock;
        } // end method setDvdStock

        // return DvdStock
        public double getDvdStock() {
            return dvdStock;
        } // end method get Dvdstock

        public void setDvdPrice(double price) {

            dvdPrice = price;
        } // end method setDvdPrice

        // return dvdPrice
        public double getDvdPrice() {
            return dvdPrice;
        } // end method get Dvd Price

        public void setDvdItem(double item) {
            dvdItem = item;
        } // end method setdvdItem

        // return DVD item
        public double getDvdItem() {
            return dvdItem;
        } // end method getDvdItem

        // calculate inventory value
        public double value() {
            return dvdPrice * dvdStock;
        } // end method value

        private double dvdPrice() {
            // TODO Auto-generated method stub
            return dvdPrice;
        }

        private void println(String string) {
            // TODO Auto-generated method stub

        }

        private double dvdStock() {
            // TODO Auto-generated method stub
            return dvdStock;
        }
{
    println("The total inventory value is: "+dvdPrice()* dvdStock());
}
}
public class DVD {


    // This sets the array for the DVD collection

    private String name;
    private int itemNumber;
    private int stockQuantity;
    private double price;

    public DVD(String name, int itemNumber, double d, double price) {

        this.name = name; // Using this. allows for the return of one dvd
                            // instead of all
        this.itemNumber = itemNumber;
        this.stockQuantity = (int) d;
        this.price = price;
    }

    public String toString() {

        return "DVD Title: " + this.name + "\n" + "Item Number: "
                + this.itemNumber + "\n" + "Stock Quantity: "
                + this.stockQuantity + "\n" + "Price: " + this.price + "\n";
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getItemNumber() {
        return this.itemNumber;
    }

    public void setItemNumber(int itemNumber) {
        this.itemNumber = itemNumber;
    }

    public int getStockQuantity() {
        return this.stockQuantity;
    }

    public void setStockQuantity(int stockQuantity) {
        this.stockQuantity = stockQuantity;
    }

    public double getPrice() {
        return this.price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    // calculate inventory value
    public double value() {
        return price * stockQuantity;
    } // end method value

    // Prints the value of inventory list.
    public void printvalue() {
        System.out.println("Inventory value...\n");
    }

    public String getDvdTitle() {
        String title = name;
        // TODO Auto-generated method stub
        return title;
    }

    public int getDvdStock() {
        // TODO Auto-generated method stub
        return stockQuantity;
    }

    public double getDvdPrice() {
        // TODO Auto-generated method stub
        return price;
    }

    public int getDvdItem() {
        // TODO Auto-generated method stub
        return itemNumber;
    }

}

// end class DVD
import java.util.Scanner;
public class Product {



    // Private variables


    Scanner input = new java.util.Scanner(System.in);
    private String name;
    private int quantity;
    private double price;
    private int productid = 0;

    // Default constructor uses other constructor to set the
    // default state of the object.

    public Product() {
        this(0, "Unknown", 0, 0.00);
    }

    // Constructor that user can specify a name, quantity, and price for for
    // items.
    public Product(int productId, String itemname, int quantityOnHand,
            double itemprice) {
        setProductid(productId);
        setName(itemname);
        setQuantityOnHand(quantityOnHand);
        setPrice(itemprice);
    }

    // Public mutators (changes state of the object)
    public void setName(String itemname) {
        name = itemname;
    }

    // Sets quantity on hand and if negative, defaults to zero.
    public void setQuantityOnHand(int quantityOnHand) {
        if (quantityOnHand > 0) {
            quantity = quantityOnHand;
        } else {
            quantity = 0;
        }
    }

    // Set price of a product and defaults it to zero if negative.
    public void setPrice(double itemPrice) {
        if (itemPrice > 0.00) {
            price = itemPrice;
        } else {
            price = 0.00;
        }
    }

    // Get the product's name
    public String getName() {
        return name;
    }

    public int getQuantityOnHand() {
        return quantity;
    }

    public double getPrice() {
        return price;
    }

    // Calculate the value of stock on this particular item.
    public double getItemValue() {
        return (price * (double) quantity);
    }

    // String representation of the product
    public String toString() {
        return name + " - " + price;
    }

    public class DVD extends Product {
        // Holds the year the move was made
        private int movieyear;

        // Constructor, calls the constructor of Product first
        // setting this instance year variable.

        public DVD(int productId, String itemname, int quantityOnHand,
                double itemprice, int year) {
            // setting name, quaintyonhand, price, year
            super(productId, itemname, quantityOnHand, itemprice);
            movieyear = year;
        }

        // to set the year manually
        public void setYear(int year) {
            movieyear = year;
        }

        // Get the year of this DVD product
        public int getYear() {
            return movieyear;
        }

        // adding a 5% restocking fee on top
        public double getItemValue() {
            return super.getItemValue() * 1.05;
        }

        // base class's value, and figures out the 5% restocking fee only
        public double getRestockingFee() {
            return super.getItemValue() * .05;
        }
    }

    public double value() {
        double value = price * quantity;
        value = 1.05 * value;
        return value;
    } // end method value

    // Prints the product list.
    public void printProduct() {
        System.out.println("Products in inventory...\n");
    }

    /**
     * @param productid
     *            the productid to set
     */
    public void setProductid(int productid) {
        this.productid = productid;
    }

    /**
     * @return the productid
     */
    public int getProductid() {
        return productid;
    }
}
import java.util.Arrays;



import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;



public class Inventory {


    private int getNumberItem;
    private int INVENTORY_SIZE;

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < numDVDs; i++) {
            sb.append(dvds[i].toString() + "\n\r");
        }

        return sb.toString();
    }

    private DVD[] dvds;
    private int numDVDs;
    private Object[] restockingFee;

    Inventory() {

        dvds = new DVD[25];
        numDVDs = 0;
    }

    // Add DVD into Inventory end
    public void addToInventory(DVD dvd) {
        dvds[numDVDs] = dvd;
        ++numDVDs;
    }

    // Adds up the total value
    public double value() {
        double total = 0;
        for (int i = 0; i < numDVDs; i++) {
            total = total + dvds[i].value();
        }
        return total;
    }

    public double restockingFee() {
        double total = 0;
        for (int i = 0; i < numDVDs; i++) {
            total = total + dvds[i].value();
        }
        return total * .05;
    }

    // return the DVDs at the location index in the inventory
    public DVD getDVD(int index) {
        return dvds[index];
    }

    // return the number of Products in the inventory
    public int getSize() {
        return numDVDs;
    }

    // sort the DVDs in the inventory by movie title
    public void sort() {
        Arrays.sort(dvds, 0, getSize());
    }

    int getNumItems() {
        return getNumberItem;
    }

    void printInventory() {

    }

    /**
     * @param iNVENTORY_SIZE
     *            the iNVENTORY_SIZE to set
     */
    public void setINVENTORY_SIZE(int iNVENTORY_SIZE) {
        INVENTORY_SIZE = iNVENTORY_SIZE;
    }

    /**
     * @return the iNVENTORY_SIZE
     */
    public int getINVENTORY_SIZE() {
        return INVENTORY_SIZE;
    }

    /**
     * @param restockingFee
     *            the restockingFee to set
     */
    public void setRestockingFee(Object[] restockingFee) {
        this.restockingFee = restockingFee;
    }

    /**
     * @return the restockingFee
     */
    public Object[] getRestockingFee() {
        return restockingFee;

    }
} // end class Inventory

class InventoryGUI extends JFrame {

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

    private Inventory theInventory;

    private int index = 0;

    private final JLabel itemNumberLabel = new JLabel("  Item Number:");
    private JTextField itemNumberText;

    private final JLabel prodnameLabel = new JLabel("  Product Name:");
    private JTextField prodnameText;

    private final JLabel prodpriceLabel = new JLabel("  Price:");
    private JTextField prodpriceText;

    private final JLabel numinstockLabel = new JLabel("  Number in Stock:");
    private JTextField numinstockText;

    private final JLabel valueLabel = new JLabel("  Value:");
    private JTextField valueText;

    private final JLabel restockingFeeLabel = new JLabel("  Restocking Fee:");
    private JTextField restockingFeeText;

    private final JLabel totalValueLabel = new JLabel(
            "  Inventory Total Value:");
    private JTextField totalValueText;
    private JPanel centerPanel;
    private JPanel buttonPanel;

    /**
     * @return the itemNumberLabel
     */
    public JLabel getItemNumberLabel() {
        return itemNumberLabel;
    }

    /**
     * @param itemNumberText
     *            the itemNumberText to set
     */
    public void setItemNumberText(JTextField itemNumberText) {
        this.itemNumberText = itemNumberText;
    }

    /**
     * @return the itemNumberText
     */
    public JTextField getItemNumberText() {
        return itemNumberText;
    }

    /**
     * @return the prodnameLabel
     */
    public JLabel getProdnameLabel() {
        return prodnameLabel;
    }

    /**
     * @param prodnameText
     *            the prodnameText to set
     */
    public void setProdnameText(JTextField prodnameText) {
        this.prodnameText = prodnameText;
    }

    /**
     * @return the prodnameText
     */
    public JTextField getProdnameText() {
        return prodnameText;
    }

    /**
     * @return the prodpriceLabel
     */
    public JLabel getProdpriceLabel() {
        return prodpriceLabel;
    }

    /**
     * @param prodpriceText
     *            the prodpriceText to set
     */
    public void setProdpriceText(JTextField prodpriceText) {
        this.prodpriceText = prodpriceText;
    }

    /**
     * @return the prodpriceText
     */
    public JTextField getProdpriceText() {
        return prodpriceText;
    }

    /**
     * @return the numinstockLabel
     */
    public JLabel getNuminstockLabel() {
        return numinstockLabel;
    }

    /**
     * @param numinstockText
     *            the numinstockText to set
     */
    public void setNuminstockText(JTextField numinstockText) {
        this.numinstockText = numinstockText;
    }

    /**
     * @return the numinstockText
     */
    public JTextField getNuminstockText() {
        return numinstockText;
    }

    /**
     * @return the valueLabel
     */
    public JLabel getValueLabel() {
        return valueLabel;
    }

    /**
     * @param valueText
     *            the valueText to set
     */
    public void setValueText(JTextField valueText) {
        this.valueText = valueText;
    }

    /**
     * @return the valueText
     */
    public JTextField getValueText() {
        return valueText;
    }

    /**
     * @return the restockingFeeLabel
     */
    public JLabel getRestockingFeeLabel() {
        return restockingFeeLabel;
    }

    /**
     * @param restockingFeeText
     *            the restockingFeeText to set
     */
    public void setRestockingFeeText(JTextField restockingFeeText) {
        this.restockingFeeText = restockingFeeText;
    }

    /**
     * @return the restockingFeeText
     */
    public JTextField getRestockingFeeText() {
        return restockingFeeText;
    }

    /**
     * @return the totalValueLabel
     */
    public JLabel getTotalValueLabel() {
        return totalValueLabel;
    }

    /**
     * @param totalValueText
     *            the totalValueText to set
     */
    public void setTotalValueText(JTextField totalValueText) {
        this.totalValueText = totalValueText;
    }

    /**
     * @return the totalValueText
     */
    public JTextField getTotalValueText() {
        return totalValueText;
    }

    /**
     * @param centerPanel
     *            the centerPanel to set
     */
    public void setCenterPanel(JPanel centerPanel) {
        this.centerPanel = centerPanel;
    }

    /**
     * @return the centerPanel
     */
    public JPanel getCenterPanel() {
        return centerPanel;
    }

    /**
     * @param buttonPanel
     *            the buttonPanel to set
     */
    public void setButtonPanel(JPanel buttonPanel) {
        this.buttonPanel = buttonPanel;
    }

    /**
     * @return the buttonPanel
     */
    public JPanel getButtonPanel() {
        return buttonPanel;
    }

    /**
     * @param theInventory
     *            the theInventory to set
     */
    public void setTheInventory(Inventory theInventory) {
        this.theInventory = theInventory;
    }

    /**
     * @return the theInventory
     */
    public Inventory getTheInventory() {
        return theInventory;
    }

    /**
     * @param index
     *            the index to set
     */
    public void setIndex(int index) {
        this.index = index;
    }

    /**
     * @return the index
     */
    public int getIndex() {
        return index;
    }

}

Recommended Answers

All 2 Replies

Please use

tags around your code.

Are you putting all the classes in one file? Java requires that each file contains only one class. I hope that it helps.

In your method main(), why are you doing new Movies(); and new java.util.Scanner(System.in); without affecting their return values to a variable of the same type?

I think that a class is by default private, so it may cause problems if you want to instantiate this class for an object. It is better to append "public" before "class" in your DVDMovies class. Also in the end of that class, you are putting a println out of nowhere and it will be never called.

Be careful, you have two DVD classes!

I doubt that you are the writer of that code...

I am using eclipse and whenever it gives me a red line then it gives options to fix it and I just keep picking options to get rid of the lines that is what there is so much code. I have four different classes
movies.java, inventory.java,product.java, dvd.java and I need to know how to make them all work together because i have a main method in the movies.java but do not know how to get the other classes to fall in line so to speak

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.