DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   Please help Errors will not compile (http://www.daniweb.com/forums/thread140433.html)

twgood Aug 15th, 2008 1:49 am
Please help Errors will not compile
 
This is due Sunday, and I still do not have all of my errors out of the way to see if it runs correctly. Please help I am down to 16 from 20.
Errors:
ompiling 1 source file to C:\NetBeansProjects\SCHOOL1\JavaApplication55\build\classes
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:146: ')' expected
getProductName(), getProductNumber(), getBaseAmount(), getBasePrice() getProductYear() );
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:146: illegal start of expression
getProductName(), getProductNumber(), getBaseAmount(), getBasePrice() getProductYear() );
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:146: not a statement
getProductName(), getProductNumber(), getBaseAmount(), getBasePrice() getProductYear() );
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:146: ';' expected
getProductName(), getProductNumber(), getBaseAmount(), getBasePrice() getProductYear() );
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:502: <identifier> expected
nextButton.addActionListener(new ActionListener() //goes to next entry on the list
^
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:502: illegal start of type
nextButton.addActionListener(new ActionListener() //goes to next entry on the list
^
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:502: ')' expected
nextButton.addActionListener(new ActionListener() //goes to next entry on the list
^
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:502: ';' expected
nextButton.addActionListener(new ActionListener() //goes to next entry on the list
^
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:502: illegal start of type
nextButton.addActionListener(new ActionListener() //goes to next entry on the list
^
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:502: <identifier> expected
nextButton.addActionListener(new ActionListener() //goes to next entry on the list
^
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:503: ';' expected
{
^
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:829: ')' expected
record.getProductName(), record.getProductNumber(), record.getBaseAmount(), record.getBasePrice(), record.getProductYear()() ,
^
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:829: illegal start of expression
record.getProductName(), record.getProductNumber(), record.getBaseAmount(), record.getBasePrice(), record.getProductYear()() ,
^
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:829: ';' expected
record.getProductName(), record.getProductNumber(), record.getBaseAmount(), record.getBasePrice(), record.getProductYear()() ,
^
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:830: not a statement
" with restock Fee $" + (roundPrice) + " value: $" + (roundValue) + " Inventory Total $" + (roundTotal) + "\t\n END OF LINE\t\t");
^
C:\NetBeansProjects\SCHOOL1\JavaApplication55\src\javaapplication55\Inventory6.java:830: ';' expected
" with restock Fee $" + (roundPrice) + " value: $" + (roundValue) + " Inventory Total $" + (roundTotal) + "\t\n END OF LINE\t\t");
^
16 errors
BUILD FAILED (total time: 0 seconds)


package javaapplication55;



import java.awt.*;  // import the java awt package
import java.awt.event.*;  // Import the java event package
import javax.swing.*; // Import the java swing package
import java.util.*; // Import the java utility package
import java.io.*; // Import the java input output package
import java.awt.Image;
import java.math.BigDecimal;
import java.math.RoundingMode;
import javax.swing.ImageIcon;

// starts the program sets up the intial inventory
public class Inventory6 {



        // main method begins execution of java application
        public static void main(String[] args) {

        FeeQtyProduct product = null;
        DvdInv inventory = new DvdInv();

        product = new FeeQtyProduct( "Legally Blonde",1, 12, 19.95,2003 );
        inventory.addFeeQtyProduct(product );

        product = new FeeQtyProduct( "Coyote Ugly", 2, 11,  18.95,2002 );
        inventory.addFeeQtyProduct(product );

        product  = new FeeQtyProduct( " How to Losse a Guy in 10 Days", 3, 12,  18.95, 2001);
        inventory.addFeeQtyProduct(product );

        product  = new FeeQtyProduct( "National Tressure", 4, 7, 18.95, 2002 );
        inventory.addFeeQtyProduct(product );

        new DvdInvGUI(inventory); // open GUI

        } // end main

} // end Inventory6


abstract class Product
{
        public String productName; //name
        public int productNumber; // product number
        private double baseAmount; // quantity in Inv
        private double basePrice; // inital price
        private int productYear; // year
        // five-argument constructor
        public Product( String name, int number, double amount, double price, int year  )
        {
                productName = name;
                productNumber = number;
                baseAmount = amount;
                basePrice = price;
                productYear = year;

        } // end five-argument Product constructor


        // set Product Name
        public void setProductName( String name )
        {
                productName = name;

        } // end method setProductName

        // return ProductName
        public String getProductName()
        {
                return productName;

        } // end method getProductName


        // set ProductNumber
        public void setProductNumber( int number )
        {
                productNumber = number; // should validate

        } // end method setProductNumber
       

        // return ProductNumber
        public int getProductNumber()
        {
                return productNumber;

        } // end method getProductNumber

        // set initial price
        public void setBaseAmount( double amount )
        {
                baseAmount = amount;

        } // end method setBaseAmount

        // return BaseAmount
        public double getBaseAmount()
        {
                return baseAmount;

        } // end method getBaseAmount

        // set BasePrice
        public void setBasePrice( double price )
        {
                basePrice = price; // non-negative

        } // end method setBasePrice

        // return BasePrice
        public double getBasePrice()
        {
                return basePrice;
        } // end method getBasePrice
       
          // set Product Year
        public void setProductYear( int year )
        {
                productYear = year;

        } // end method setProductYear

        // return ProductYear
        public int getProductYear()
        {
                return productYear;

        } // end method getProductYear
                 

        // return String representation of Product object no longer needed

     
          @Override
        public String toString()
        {
               
    return String.format( "%s\nProduct#: %f\nQTY#:%.0f\nPrice: $%.2f, %f\nYear# ",
    getProductName(), getProductNumber(), getBaseAmount(), getBasePrice() getProductYear() );
        } // end method toString

        // abstract method overridden by subclasses

                public abstract double total(); // no implementation here
                public abstract double restock(); // no implementation here

} // end abstract class Product

 
class FeeQtyProduct  extends Product
{

       

        // five-argument constructor
        public FeeQtyProduct( String name, int number, double amount, double price, int year )
        {
                super( name, number, amount, price, year );}


                // calculate total; override method total in Product
        public double total()
        {
                return getBasePrice() * getBaseAmount();

        } // end method total
       

        // calculate earnings; override method total in QtyProduct
        public double restock()
        {
               
        return getBasePrice() * 1.05;
       
       
        } // end method restock
       

} // end class FeeQtyProduct
       
// create inventory list
class DvdInv
{
       
        // delare variables
        public static final int INVENTORY_SIZE = 30;
        private FeeQtyProduct[] items;
        public int numItems;

                DvdInv() //sets the number of items
                {

                        items = new FeeQtyProduct[INVENTORY_SIZE];
                        numItems = 0;


}
                //returns number of items
                public int getNumItems()
                {
                        return numItems;
                }
               
                //returns each product
                public FeeQtyProduct getFeeQtyProduct(int i)
                {
                        return items[i];
                }       

                //deletes item and recounts number of items
                public void remove(int i)
                {

                        items[i] = items[numItems -1];
                        --numItems;       

                }
                //adds products to the inventory
                public void addFeeQtyProduct( FeeQtyProduct item)
                {
                        items[numItems] = item;
                        ++numItems;
                }
                // reduces numbers of items in inventory
                public void removeFeeQtyProduct(FeeQtyProduct item)
                {
                        items[numItems] = item;
                        --numItems;
                }
                // returns the amount one item inventory is worth
                public double value()
                {
                        double sum = 0.0;

                        for (int i = 0; i < numItems; i++)
                        sum += items[i].total();

                        return sum;

                }// end double value




} // end DvdInv
// draw company logo
class ArcsJPanel extends JPanel
{
       
    @Override
        public void paintComponent( Graphics g )
        {
                super.paintComponent( g ); // call superclass's paintComponent

                // draws larger 3d rectangle
                g.setColor( Color.PINK );
                g.draw3DRect( 45, 15, 180, 40, true);
               
                // draws small black square
                g.setColor( Color.BLACK );
                g.draw3DRect( 5, 15, 40, 40, true );
                g.fill3DRect( 5, 15, 40, 40, false );
               
                //draws circle
                g.setColor( Color.PINK );
                g.drawArc( 5, 15, 40, 40, 10, 360 );
               
                //fills circle
                g.setColor( Color.WHITE);
                g.fillArc( 5, 15, 40, 40, 10, 360 );

                // draws company name
                g.setColor( Color.BLACK );
                g.setFont( new Font( "Serif", Font.BOLD, 25 ) );
                g.drawString( "CD Inventory.", 10, 45 );

        } // end method paintComponent

 } // end class ArcsJPanel


// GUI for the Inventory
class DvdInvGUI extends JFrame
{


        private DvdInv myDvdInv;

        public int index = 0;

        // GUI elements to display information

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

        private final JLabel movieLabel = new JLabel( "Movie:");
        private JTextField movieText;

        private final JLabel yearLabel = new JLabel("Year:");
        private JTextField yearText;

        private final JLabel priceLabel = new JLabel(" Price: $");
        private JTextField priceText;

        private final JLabel qtyLabel = new JLabel(" Quantity:");
        private JTextField qtyText;

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

        private final JLabel restockFeeLabel = new JLabel(" with Restock Fee:");
        private JTextField restockFeeText;

        private final JLabel totalValueLabel = new JLabel(" Inventory Total Value:");
        private JTextField totalValueText;
       
        private final JLabel searchLabel = new JLabel("Search:");
        private JTextField searchText;
       

// constructor for the GUI, in charge of creating all GUI elements
        DvdInvGUI(DvdInv inventory)
        {

                ArcsJPanel arcsJPanel = new ArcsJPanel(); // create ArcsJPanel
                final Dimension size = new Dimension(125,20);
                final Dimension size2 = new Dimension(300,60);
                final FlowLayout layout = new FlowLayout(FlowLayout.LEFT);
                JPanel jpanel = new JPanel();
                JPanel  buttonPanel = new JPanel();
                buttonPanel.setLayout(new GridLayout(2, 4));
                JPanel centerPanel = new JPanel();
                centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));
       

                // create the inventory object that will hold the product information
                myDvdInv = inventory;

                // setup the GUI
                // product information
                // setup a panel to collect all the components.
       

                JButton firstButton = new JButton("First");
                buttonPanel.add(firstButton);

                JButton previousButton = new JButton("Previous");
                buttonPanel.add(previousButton);

                JButton nextButton = new JButton("Next");
                buttonPanel.add(nextButton);

                JButton lastButton = new JButton("Last");
                buttonPanel.add(lastButton);

                JButton addButton = new JButton("Add");
                buttonPanel.add(addButton);

                JButton deleteButton = new JButton("Delete");
                buttonPanel.add(deleteButton);

                JButton modifyButton = new JButton("Modify");
                buttonPanel.add(modifyButton);

                JButton saveButton = new JButton("Save");
                buttonPanel.add(saveButton);

                JButton searchButton = new JButton("Search");
                buttonPanel.add(searchButton);       

                JButton helpButton = new JButton("help");
                buttonPanel.add(helpButton);       

                // start JPanel layout
                jpanel = new JPanel(layout);
                arcsJPanel.setPreferredSize(size2);
                jpanel.add(arcsJPanel);
                centerPanel.add(jpanel);

                jpanel = new JPanel(layout);
                itemNumberLabel.setPreferredSize(size);
                jpanel.add(itemNumberLabel);
                itemNumberText = new JTextField(3);
                itemNumberText.setEditable(false);
                jpanel.add(itemNumberText);
                centerPanel.add(jpanel);

                jpanel = new JPanel(layout);
                movieLabel.setPreferredSize(size);
                jpanel.add(movieLabel);
                movieText = new JTextField(10);
                movieText.setEditable(true); 
                jpanel.add(movieText);
                centerPanel.add(jpanel);

                jpanel = new JPanel(layout);
                yearLabel.setPreferredSize(size);
                jpanel.add(yearLabel);
                yearText = new JTextField(10);
                yearText.setEditable(true);
                jpanel.add(yearText);
                centerPanel.add(jpanel);

                jpanel = new JPanel(layout);
                priceLabel.setPreferredSize(size);
                jpanel.add(priceLabel);
                priceText = new JTextField(10);
                priceText.setEditable(true);
                jpanel.add(priceText);
                centerPanel.add(jpanel);

                jpanel = new JPanel(layout);
                qtyLabel.setPreferredSize(size);
                jpanel.add(qtyLabel);
                qtyText = new JTextField(5);
                qtyText.setEditable(true);
                jpanel.add(qtyText);
                centerPanel.add(jpanel);

                jpanel = new JPanel(layout);
                restockFeeLabel.setPreferredSize(size);
                jpanel.add(restockFeeLabel);
                restockFeeText = new JTextField(5);
                restockFeeText.setEditable(false);
                jpanel.add(restockFeeText);
                centerPanel.add(jpanel);

                jpanel = new JPanel(layout);
                valueLabel.setPreferredSize(size);
                jpanel.add(valueLabel);
                valueText = new JTextField(5);
                valueText.setEditable(false);
                jpanel.add(valueText);
                centerPanel.add(jpanel);

                jpanel = new JPanel(layout);
                totalValueLabel.setPreferredSize(size);
                jpanel.add(totalValueLabel);
                totalValueText = new JTextField(5);
                totalValueText.setEditable(false);
                jpanel.add(totalValueText);
                centerPanel.add(jpanel);


                jpanel = new JPanel(layout);
                searchLabel.setPreferredSize(size);
                jpanel.add(searchLabel);
                searchText = new JTextField(10);
                searchText.setEditable(true);
                jpanel.add(searchText);
                centerPanel.add(jpanel);
               
JFrame frame = new JFrame("DVD Inventory Program"); // JFrame container       
                frame.setLayout(new BorderLayout()); // set layout
                frame.add(buttonPanel, BorderLayout.SOUTH); // adds buttons to frame
                frame.add(centerPanel, BorderLayout.CENTER); // adds center panel to frame
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // terminate upon close
                frame.setSize(375, 425); // set size
                frame.setResizable(true);
                frame.setLocationRelativeTo(null); // set location
                frame.setVisible(true); // display the window
    repaintGUI();

    // start inner classes to add actions to buttons
    firstButton.addActionListener(new ActionListener() //goes to first entry
    {
        public void actionPerformed(ActionEvent e)
        {
            index = 0;
            repaintGUI();

                }// end action

        });// end class


        previousButton.addActionListener(new ActionListener() //allows user to add entry
        {
                public void actionPerformed(ActionEvent e)
                {
                    int numItems = myDvdInv.getNumItems();
                                if (numItems != 0)
                                        index = (--index) % numItems;

                                        if (index < 0)
                                        index = numItems - 1;       

                                if (numItems == 0) // catches for last entry not needed because we add a blank entry at zero but just in case
                                        JOptionPane.showMessageDialog(null, "That's the last entry.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);

                        repaintGUI();
                }


        nextButton.addActionListener(new ActionListener() //goes to next entry on the list
        {
                public void actionPerformed(ActionEvent e)
                {
                        int numItems = myDvdInv.getNumItems();
                        index = (++index) % numItems; // moves index up one
                        repaintGUI();

                       
                }// end action

        }); // end class

        lastButton.addActionListener(new ActionListener() 
        {
                public void actionPerformed(ActionEvent e)
                {
                        int numItems = myDvdInv.getNumItems();
                        index = (numItems -1) % numItems; //goes to first entry then minus one
                        repaintGUI();

                }// end action

        }); // end clas

        addButton.addActionListener(new ActionListener() 
        {

                public void actionPerformed(ActionEvent e)
                {
                        FeeQtyProduct temp = (FeeQtyProduct) myDvdInv.getFeeQtyProduct(index);
                        int numItems = myDvdInv.getNumItems() +1;

                                index = (numItems - 2) % numItems;
                                repaintGUI();


                        if(movieText.getText().equals("Add Movie Name" )) // catches for assigning more then one blank at a time
                        {
                                JOptionPane.showMessageDialog(null, "Please fill out the blank entry you already have before adding more\nRemember: Push Modify when you finish with your changes","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
                        }
                       
                        if(movieText.getText().equals("Add Movie Name" ) !=true) // allows the adding of an entry
                        {
                                FeeQtyProduct product = new FeeQtyProduct( "Add Movie Name", Integer.parseInt(itemNumberText.getText()) + 1, 0, 0.0,0 );
                                index = (numItems - 1) % numItems;
                                myDvdInv.addFeeQtyProduct(product );
                                repaintGUI();
                        }
                        if (numItems == 29) // catches for going over static inventory size
                        { 
                                myDvdInv.removeFeeQtyProduct(temp);
                                JOptionPane.showMessageDialog(null, "Please No More Entries\n You can increase my capacity in the java file CdInvApp.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
                        }

                }// end action

        }); // end class

        saveButton.addActionListener(new ActionListener() // saves the dat file in English
        {
                public void actionPerformed(ActionEvent e)
                {
                        int numItems = myDvdInv.getNumItems();
                        InventoryStorage record = new InventoryStorage(); //calls inventroy storage class
                        record.openFile();
                        int currentRecord = 0; // keeps track of number of cycles

                        do // cycles through the list adding them one at a time
                        {
                                record.addRecords();
                                currentRecord = currentRecord + 1;
                                index = (++index) % numItems;

                        } while (currentRecord < numItems); //ends while

                                record.closeFile(); //closes file
                }//end action

        });  // end class

        modifyButton.addActionListener(new ActionListener() // saves changes to the GUI
        {
               
                public void actionPerformed(ActionEvent e)
                {

                        if (movieText.getText().equals(""))  //traps for blank entry
                        {
                                JOptionPane.showMessageDialog(null, "Please Complete the Entry.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
                                repaintGUI();
                        }


                        if (yearText.getText().equals(""))  //traps for blank entry
                        {
                                JOptionPane.showMessageDialog(null, "Please Complete the Entry.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
                                repaintGUI();
                        }

                        try // traps for letters and blank entry
                        {
                       
                                Double.parseDouble(qtyText.getText());
                                Double.parseDouble(priceText.getText());
                               
                            }
                            catch (Exception d)
                            {
                                JOptionPane.showMessageDialog(null, "Recheck Entry use numbers for price and quantity.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
                                repaintGUI();
                            }


                        String name; int number; double amount, price; int year; // declares variables
                       
                        name = yearText.getText();
                        number = Integer.parseInt(itemNumberText.getText());
                        amount = Double.parseDouble(qtyText.getText());
                        price = Double.parseDouble(priceText.getText());
                        year = Integer.parseInt(yearText.getText());
               

                FeeQtyProduct modify =  (FeeQtyProduct) myDvdInv.getFeeQtyProduct(index);       

                        modify.setProductNumber(number);
                        modify.setProductName(name);
                        modify.setBaseAmount(amount);
                        modify.setBasePrice(price);
                        modify.setProductYear(year);
                        repaintGUI();
                }

        }); // end class

        deleteButton.addActionListener(new ActionListener()  //allows user to delete entry and sorts product numbers to be in sequence
        {
                public void actionPerformed(ActionEvent e)
                {

                        int numItems = myDvdInv.getNumItems();
                        FeeQtyProduct temp = (FeeQtyProduct) myDvdInv.getFeeQtyProduct(index);

                        if (numItems != 0)
                        {

                                if(Integer.parseInt(itemNumberText.getText()) != numItems)
                                {
                                       
                                        myDvdInv.remove(index);
                                        repaintGUI();
                                        int i = Integer.parseInt(itemNumberText.getText());
                                        index = (++index) % numItems;
                                        repaintGUI();
                                        int j = Integer.parseInt(itemNumberText.getText());
                               
                                        if (i > j)// my own little sort mechanism to keep Product numbers in sequence
                                                index = (-- index) % numItems;
                                                repaintGUI();
                                                temp = (FeeQtyProduct) myDvdInv.getFeeQtyProduct(index);
                                                temp.setProductNumber(j-1);
                                                index = (++index) % numItems;
                                                repaintGUI();

                                }// end if
                                       
                                if(Integer.parseInt(itemNumberText.getText()) == numItems) // uses a different method to remove entry if it is the last one prevents blank entry from being in the mix
                                {
                                        myDvdInv.removeFeeQtyProduct(temp);
                                        index = (++index) % numItems;
                                        repaintGUI();
                                }//end if

                        }// end if
                       
                        if (numItems == 1) // catches for 0 items error
                        {
                               
                                FeeQtyProduct product = new FeeQtyProduct( "Add Movie Name",numItems, 0, 0.0,0);
                                myDvdInv.addFeeQtyProduct(product);
                                JOptionPane.showMessageDialog(null, "Delete Process Complete.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
                                repaintGUI();
                        } //end if


                }// end action



        }); // end class

        searchButton.addActionListener(new ActionListener() 
        {
                public void actionPerformed(ActionEvent e)
                {       
                        //declare variables and gets text from GUI
                        String search = searchText.getText();
                        String name = movieText.getText();
                        int number = Integer.parseInt(itemNumberText.getText());
                        int numItems = myDvdInv.getNumItems();
                        int currentRecord = 0;
       
                        do // gets text and checks for a match
                        {       
                                index = (++index) % numItems;
                                repaintGUI();
                                name = movieText.getText();
                                number = Integer.parseInt(itemNumberText.getText());
                                search = searchText.getText();
                                currentRecord = (++currentRecord);

                                if(name.equalsIgnoreCase( search )) // stops on item
                                        repaintGUI();

                                if(searchText.getText().equals("" )) //catches for no entry in the search box
                                {
                                        JOptionPane.showMessageDialog(null, "What would you like to search for?","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
                                        index = (--index) % numItems;
                                        break;
                                }

                                if(currentRecord == numItems +1) // displays message if no results match search
                                {
                                        JOptionPane.showMessageDialog(null, "No Results Found","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
                                        break;
                                }
               

                        }while(name.equalsIgnoreCase(search ) != true); //ends do while
     

                }//end action

     
        }); // end class
        helpButton.addActionListener(new ActionListener()  // this is basically to tell you what to do with the program
        {
                public void actionPerformed(ActionEvent e)
                {
                        JOptionPane.showMessageDialog(null, "FIRST Brings you to the first entry\nPREVIOUS  Brings you to the last entry\nNEXT  Brings you to the next entry\nLAST Brings you to the last entry\nADD                        adds a blank entry to allow a new listing see (MODIFY)\nSAVE  Exports the entry's to a DAT file\nSEARCH allows you to search by product name\nMODIFY must be pressed to save changes                                within the GUI\nDELETE deletes the entry\nHELP  you are in help\n","HELP", JOptionPane.PLAIN_MESSAGE);
                        repaintGUI();
                }

        }); // end class


} // end DvdInvGUI
        class InventoryStorage // creates the output file
{
        private Formatter output; // object used to output text to file

                public void openFile()
                {
                        try
                        {
                                    String strDirectoy ="C://data/";

                                    // Create one directory
                                    boolean success = (new File(strDirectoy)).mkdir();
                                   
                                if (success)
                                {

                                              JOptionPane.showMessageDialog(null, "we had to create a directory named data in your C drive.","That's affirmative", JOptionPane.PLAIN_MESSAGE);

                                    }  //end if


                        }//end try

                        catch (Exception e)
                        {
                         
                               
                                      JOptionPane.showMessageDialog(null, "You do not have write access to the C: drive.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);

                            }//end catch
 


                        try
                        {
                               
                                              output = new Formatter( "C:/data/inventory.dat");

                        } // end try

                catch ( SecurityException securityException ) //catches for write access and exits program
                {
                        JOptionPane.showMessageDialog(null, "You do not have write access to this file.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
                        System.exit( 1 );

                } // end catch

                catch ( FileNotFoundException filesNotFoundException ) //catches for write access and exits program
                {
                        JOptionPane.showMessageDialog(null, "Please create a file named data in your c drive","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
                        System.exit( 1 );

                } // end catch


                JOptionPane.showMessageDialog(null, "file saved successfully.","That's affirmative", JOptionPane.PLAIN_MESSAGE);



        } // end method openFile
public void addRecords() // adds the records to the file
        {

                FeeQtyProduct record = (FeeQtyProduct) myDvdInv.getFeeQtyProduct(index);
                       
                        // rounds the output numbers to 2 decimals

                        BigDecimal roundPrice = new BigDecimal(Double.toString(record.restock() ));   
                        roundPrice = roundPrice.setScale(2, RoundingMode.HALF_UP);

                        BigDecimal roundValue= new BigDecimal(Double.toString(record.total()));   
                        roundValue= roundValue.setScale(2, RoundingMode.HALF_UP);

                        BigDecimal roundTotal= new BigDecimal(Double.toString(myDvdInv.value()));   
                        roundTotal = roundTotal.setScale(2, RoundingMode.HALF_UP);
               
               
                if (record != null) //catches for blank record - overkill because we can never have a blank record
                {
                        output.format( "Artist:%s Product#: %s QTY#:%.0f Price: $%.2f%s: %s" ,
                        record.getProductName(), record.getProductNumber(), record.getBaseAmount(), record.getBasePrice(), record.getProductYear()() ,
                        "  with restock Fee $" + (roundPrice) + "  value: $" + (roundValue) + " Inventory Total $" + (roundTotal) + "\t\n END OF LINE\t\t");

                } // end if
                        } // end addRecords

        public void closeFile() // close the file
        {
                if ( output != null )
                output.close();

        } // end method closeFile

}// end InventoryStorage class


        // display GUI
        public void repaintGUI()
        {

                FeeQtyProduct temp = (FeeQtyProduct) myDvdInv.getFeeQtyProduct(index);

        if(temp != null) //catches for no entries
        {
                itemNumberText.setText("" + temp.getProductNumber());
                movieText.setText(temp.getProductName());
                yearText.setText(String.format("%s", temp.getProductYear()));
                priceText.setText(String.format("%.2f", temp.getBasePrice()));
                restockFeeText.setText(String.format("$%.2f", temp.restock()));
                qtyText.setText(String.format("%.0f",temp.getBaseAmount()));
                valueText.setText(String.format("$%.2f", temp.total()));
               

        }// end if
                totalValueText.setText(String.format("$%.2f", myDvdInv.value()));

        } // end repaintGUI

} // End InventoryGUI class

peter_budo Aug 15th, 2008 5:18 am
Re: Please help Errors will not compile
 
missing comma between getBasePrice(), getProductYear()
public String toString()
{               
    return String.format( "%s\nProduct#: %f\nQTY#:%.0f\nPrice: $%.2f, %f\nYear# ",
    getProductName(), getProductNumber(), getBaseAmount(), getBasePrice(), getProductYear() );
        } // end method toString
missing closing brackets });
previousButton.addActionListener(new ActionListener() 
{
      //rest of the code
});
extra brackets on record.getProductYear()()
public void addRecords() 
{
      //rest of the code
        if (record != null) //catches for blank record - overkill because we can never have a blank record
        {
                output.format( "Artist:%s Product#: %s QTY#:%.0f Price: $%.2f%s: %s" , record.getProductName(), record.getProductNumber(), record.getBaseAmount(), record.getBasePrice(), record.getProductYear() , "  with restock Fee $" + (roundPrice) + "  value: $" + (roundValue) + " Inventory Total $" + (roundTotal) + "\t\n END OF LINE\t\t");
        } // end if
Pay more attention to errors you getting and go and see the error line. All of the reported errors been self-explanatory to me.


All times are GMT -4. The time now is 3:31 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC