Please help Errors will not compile

Reply

Join Date: May 2008
Posts: 34
Reputation: twgood is an unknown quantity at this point 
Solved Threads: 0
twgood twgood is offline Offline
Light Poster

Please help Errors will not compile

 
0
  #1
Aug 15th, 2008
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)

  1.  
  2. package javaapplication55;
  3.  
  4.  
  5.  
  6. import java.awt.*; // import the java awt package
  7. import java.awt.event.*; // Import the java event package
  8. import javax.swing.*; // Import the java swing package
  9. import java.util.*; // Import the java utility package
  10. import java.io.*; // Import the java input output package
  11. import java.awt.Image;
  12. import java.math.BigDecimal;
  13. import java.math.RoundingMode;
  14. import javax.swing.ImageIcon;
  15.  
  16. // starts the program sets up the intial inventory
  17. public class Inventory6 {
  18.  
  19.  
  20.  
  21. // main method begins execution of java application
  22. public static void main(String[] args) {
  23.  
  24. FeeQtyProduct product = null;
  25. DvdInv inventory = new DvdInv();
  26.  
  27. product = new FeeQtyProduct( "Legally Blonde",1, 12, 19.95,2003 );
  28. inventory.addFeeQtyProduct(product );
  29.  
  30. product = new FeeQtyProduct( "Coyote Ugly", 2, 11, 18.95,2002 );
  31. inventory.addFeeQtyProduct(product );
  32.  
  33. product = new FeeQtyProduct( " How to Losse a Guy in 10 Days", 3, 12, 18.95, 2001);
  34. inventory.addFeeQtyProduct(product );
  35.  
  36. product = new FeeQtyProduct( "National Tressure", 4, 7, 18.95, 2002 );
  37. inventory.addFeeQtyProduct(product );
  38.  
  39. new DvdInvGUI(inventory); // open GUI
  40.  
  41. } // end main
  42.  
  43. } // end Inventory6
  44.  
  45.  
  46. abstract class Product
  47. {
  48. public String productName; //name
  49. public int productNumber; // product number
  50. private double baseAmount; // quantity in Inv
  51. private double basePrice; // inital price
  52. private int productYear; // year
  53. // five-argument constructor
  54. public Product( String name, int number, double amount, double price, int year )
  55. {
  56. productName = name;
  57. productNumber = number;
  58. baseAmount = amount;
  59. basePrice = price;
  60. productYear = year;
  61.  
  62. } // end five-argument Product constructor
  63.  
  64.  
  65. // set Product Name
  66. public void setProductName( String name )
  67. {
  68. productName = name;
  69.  
  70. } // end method setProductName
  71.  
  72. // return ProductName
  73. public String getProductName()
  74. {
  75. return productName;
  76.  
  77. } // end method getProductName
  78.  
  79.  
  80. // set ProductNumber
  81. public void setProductNumber( int number )
  82. {
  83. productNumber = number; // should validate
  84.  
  85. } // end method setProductNumber
  86.  
  87.  
  88. // return ProductNumber
  89. public int getProductNumber()
  90. {
  91. return productNumber;
  92.  
  93. } // end method getProductNumber
  94.  
  95. // set initial price
  96. public void setBaseAmount( double amount )
  97. {
  98. baseAmount = amount;
  99.  
  100. } // end method setBaseAmount
  101.  
  102. // return BaseAmount
  103. public double getBaseAmount()
  104. {
  105. return baseAmount;
  106.  
  107. } // end method getBaseAmount
  108.  
  109. // set BasePrice
  110. public void setBasePrice( double price )
  111. {
  112. basePrice = price; // non-negative
  113.  
  114. } // end method setBasePrice
  115.  
  116. // return BasePrice
  117. public double getBasePrice()
  118. {
  119. return basePrice;
  120. } // end method getBasePrice
  121.  
  122. // set Product Year
  123. public void setProductYear( int year )
  124. {
  125. productYear = year;
  126.  
  127. } // end method setProductYear
  128.  
  129. // return ProductYear
  130. public int getProductYear()
  131. {
  132. return productYear;
  133.  
  134. } // end method getProductYear
  135.  
  136.  
  137. // return String representation of Product object no longer needed
  138.  
  139.  
  140. @Override
  141. public String toString()
  142. {
  143.  
  144. return String.format( "%s\nProduct#: %f\nQTY#:%.0f\nPrice: $%.2f, %f\nYear# ",
  145. getProductName(), getProductNumber(), getBaseAmount(), getBasePrice() getProductYear() );
  146. } // end method toString
  147.  
  148. // abstract method overridden by subclasses
  149.  
  150. public abstract double total(); // no implementation here
  151. public abstract double restock(); // no implementation here
  152.  
  153. } // end abstract class Product
  154.  
  155.  
  156. class FeeQtyProduct extends Product
  157. {
  158.  
  159.  
  160.  
  161. // five-argument constructor
  162. public FeeQtyProduct( String name, int number, double amount, double price, int year )
  163. {
  164. super( name, number, amount, price, year );}
  165.  
  166.  
  167. // calculate total; override method total in Product
  168. public double total()
  169. {
  170. return getBasePrice() * getBaseAmount();
  171.  
  172. } // end method total
  173.  
  174.  
  175. // calculate earnings; override method total in QtyProduct
  176. public double restock()
  177. {
  178.  
  179. return getBasePrice() * 1.05;
  180.  
  181.  
  182. } // end method restock
  183.  
  184.  
  185. } // end class FeeQtyProduct
  186.  
  187. // create inventory list
  188. class DvdInv
  189. {
  190.  
  191. // delare variables
  192. public static final int INVENTORY_SIZE = 30;
  193. private FeeQtyProduct[] items;
  194. public int numItems;
  195.  
  196. DvdInv() //sets the number of items
  197. {
  198.  
  199. items = new FeeQtyProduct[INVENTORY_SIZE];
  200. numItems = 0;
  201.  
  202.  
  203. }
  204. //returns number of items
  205. public int getNumItems()
  206. {
  207. return numItems;
  208. }
  209.  
  210. //returns each product
  211. public FeeQtyProduct getFeeQtyProduct(int i)
  212. {
  213. return items[i];
  214. }
  215.  
  216. //deletes item and recounts number of items
  217. public void remove(int i)
  218. {
  219.  
  220. items[i] = items[numItems -1];
  221. --numItems;
  222.  
  223. }
  224. //adds products to the inventory
  225. public void addFeeQtyProduct( FeeQtyProduct item)
  226. {
  227. items[numItems] = item;
  228. ++numItems;
  229. }
  230. // reduces numbers of items in inventory
  231. public void removeFeeQtyProduct(FeeQtyProduct item)
  232. {
  233. items[numItems] = item;
  234. --numItems;
  235. }
  236. // returns the amount one item inventory is worth
  237. public double value()
  238. {
  239. double sum = 0.0;
  240.  
  241. for (int i = 0; i < numItems; i++)
  242. sum += items[i].total();
  243.  
  244. return sum;
  245.  
  246. }// end double value
  247.  
  248.  
  249.  
  250.  
  251. } // end DvdInv
  252. // draw company logo
  253. class ArcsJPanel extends JPanel
  254. {
  255.  
  256. @Override
  257. public void paintComponent( Graphics g )
  258. {
  259. super.paintComponent( g ); // call superclass's paintComponent
  260.  
  261. // draws larger 3d rectangle
  262. g.setColor( Color.PINK );
  263. g.draw3DRect( 45, 15, 180, 40, true);
  264.  
  265. // draws small black square
  266. g.setColor( Color.BLACK );
  267. g.draw3DRect( 5, 15, 40, 40, true );
  268. g.fill3DRect( 5, 15, 40, 40, false );
  269.  
  270. //draws circle
  271. g.setColor( Color.PINK );
  272. g.drawArc( 5, 15, 40, 40, 10, 360 );
  273.  
  274. //fills circle
  275. g.setColor( Color.WHITE);
  276. g.fillArc( 5, 15, 40, 40, 10, 360 );
  277.  
  278. // draws company name
  279. g.setColor( Color.BLACK );
  280. g.setFont( new Font( "Serif", Font.BOLD, 25 ) );
  281. g.drawString( "CD Inventory.", 10, 45 );
  282.  
  283. } // end method paintComponent
  284.  
  285. } // end class ArcsJPanel
  286.  
  287.  
  288. // GUI for the Inventory
  289. class DvdInvGUI extends JFrame
  290. {
  291.  
  292.  
  293. private DvdInv myDvdInv;
  294.  
  295. public int index = 0;
  296.  
  297. // GUI elements to display information
  298.  
  299. private final JLabel itemNumberLabel = new JLabel(" Item Number:");
  300. public JTextField itemNumberText;
  301.  
  302. private final JLabel movieLabel = new JLabel( "Movie:");
  303. private JTextField movieText;
  304.  
  305. private final JLabel yearLabel = new JLabel("Year:");
  306. private JTextField yearText;
  307.  
  308. private final JLabel priceLabel = new JLabel(" Price: $");
  309. private JTextField priceText;
  310.  
  311. private final JLabel qtyLabel = new JLabel(" Quantity:");
  312. private JTextField qtyText;
  313.  
  314. private final JLabel valueLabel = new JLabel(" Value:");
  315. private JTextField valueText;
  316.  
  317. private final JLabel restockFeeLabel = new JLabel(" with Restock Fee:");
  318. private JTextField restockFeeText;
  319.  
  320. private final JLabel totalValueLabel = new JLabel(" Inventory Total Value:");
  321. private JTextField totalValueText;
  322.  
  323. private final JLabel searchLabel = new JLabel("Search:");
  324. private JTextField searchText;
  325.  
  326.  
  327. // constructor for the GUI, in charge of creating all GUI elements
  328. DvdInvGUI(DvdInv inventory)
  329. {
  330.  
  331. ArcsJPanel arcsJPanel = new ArcsJPanel(); // create ArcsJPanel
  332. final Dimension size = new Dimension(125,20);
  333. final Dimension size2 = new Dimension(300,60);
  334. final FlowLayout layout = new FlowLayout(FlowLayout.LEFT);
  335. JPanel jpanel = new JPanel();
  336. JPanel buttonPanel = new JPanel();
  337. buttonPanel.setLayout(new GridLayout(2, 4));
  338. JPanel centerPanel = new JPanel();
  339. centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));
  340.  
  341.  
  342. // create the inventory object that will hold the product information
  343. myDvdInv = inventory;
  344.  
  345. // setup the GUI
  346. // product information
  347. // setup a panel to collect all the components.
  348.  
  349.  
  350. JButton firstButton = new JButton("First");
  351. buttonPanel.add(firstButton);
  352.  
  353. JButton previousButton = new JButton("Previous");
  354. buttonPanel.add(previousButton);
  355.  
  356. JButton nextButton = new JButton("Next");
  357. buttonPanel.add(nextButton);
  358.  
  359. JButton lastButton = new JButton("Last");
  360. buttonPanel.add(lastButton);
  361.  
  362. JButton addButton = new JButton("Add");
  363. buttonPanel.add(addButton);
  364.  
  365. JButton deleteButton = new JButton("Delete");
  366. buttonPanel.add(deleteButton);
  367.  
  368. JButton modifyButton = new JButton("Modify");
  369. buttonPanel.add(modifyButton);
  370.  
  371. JButton saveButton = new JButton("Save");
  372. buttonPanel.add(saveButton);
  373.  
  374. JButton searchButton = new JButton("Search");
  375. buttonPanel.add(searchButton);
  376.  
  377. JButton helpButton = new JButton("help");
  378. buttonPanel.add(helpButton);
  379.  
  380. // start JPanel layout
  381. jpanel = new JPanel(layout);
  382. arcsJPanel.setPreferredSize(size2);
  383. jpanel.add(arcsJPanel);
  384. centerPanel.add(jpanel);
  385.  
  386. jpanel = new JPanel(layout);
  387. itemNumberLabel.setPreferredSize(size);
  388. jpanel.add(itemNumberLabel);
  389. itemNumberText = new JTextField(3);
  390. itemNumberText.setEditable(false);
  391. jpanel.add(itemNumberText);
  392. centerPanel.add(jpanel);
  393.  
  394. jpanel = new JPanel(layout);
  395. movieLabel.setPreferredSize(size);
  396. jpanel.add(movieLabel);
  397. movieText = new JTextField(10);
  398. movieText.setEditable(true);
  399. jpanel.add(movieText);
  400. centerPanel.add(jpanel);
  401.  
  402. jpanel = new JPanel(layout);
  403. yearLabel.setPreferredSize(size);
  404. jpanel.add(yearLabel);
  405. yearText = new JTextField(10);
  406. yearText.setEditable(true);
  407. jpanel.add(yearText);
  408. centerPanel.add(jpanel);
  409.  
  410. jpanel = new JPanel(layout);
  411. priceLabel.setPreferredSize(size);
  412. jpanel.add(priceLabel);
  413. priceText = new JTextField(10);
  414. priceText.setEditable(true);
  415. jpanel.add(priceText);
  416. centerPanel.add(jpanel);
  417.  
  418. jpanel = new JPanel(layout);
  419. qtyLabel.setPreferredSize(size);
  420. jpanel.add(qtyLabel);
  421. qtyText = new JTextField(5);
  422. qtyText.setEditable(true);
  423. jpanel.add(qtyText);
  424. centerPanel.add(jpanel);
  425.  
  426. jpanel = new JPanel(layout);
  427. restockFeeLabel.setPreferredSize(size);
  428. jpanel.add(restockFeeLabel);
  429. restockFeeText = new JTextField(5);
  430. restockFeeText.setEditable(false);
  431. jpanel.add(restockFeeText);
  432. centerPanel.add(jpanel);
  433.  
  434. jpanel = new JPanel(layout);
  435. valueLabel.setPreferredSize(size);
  436. jpanel.add(valueLabel);
  437. valueText = new JTextField(5);
  438. valueText.setEditable(false);
  439. jpanel.add(valueText);
  440. centerPanel.add(jpanel);
  441.  
  442. jpanel = new JPanel(layout);
  443. totalValueLabel.setPreferredSize(size);
  444. jpanel.add(totalValueLabel);
  445. totalValueText = new JTextField(5);
  446. totalValueText.setEditable(false);
  447. jpanel.add(totalValueText);
  448. centerPanel.add(jpanel);
  449.  
  450.  
  451. jpanel = new JPanel(layout);
  452. searchLabel.setPreferredSize(size);
  453. jpanel.add(searchLabel);
  454. searchText = new JTextField(10);
  455. searchText.setEditable(true);
  456. jpanel.add(searchText);
  457. centerPanel.add(jpanel);
  458.  
  459. JFrame frame = new JFrame("DVD Inventory Program"); // JFrame container
  460. frame.setLayout(new BorderLayout()); // set layout
  461. frame.add(buttonPanel, BorderLayout.SOUTH); // adds buttons to frame
  462. frame.add(centerPanel, BorderLayout.CENTER); // adds center panel to frame
  463. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // terminate upon close
  464. frame.setSize(375, 425); // set size
  465. frame.setResizable(true);
  466. frame.setLocationRelativeTo(null); // set location
  467. frame.setVisible(true); // display the window
  468. repaintGUI();
  469.  
  470. // start inner classes to add actions to buttons
  471. firstButton.addActionListener(new ActionListener() //goes to first entry
  472. {
  473. public void actionPerformed(ActionEvent e)
  474. {
  475. index = 0;
  476. repaintGUI();
  477.  
  478. }// end action
  479.  
  480. });// end class
  481.  
  482.  
  483. previousButton.addActionListener(new ActionListener() //allows user to add entry
  484. {
  485. public void actionPerformed(ActionEvent e)
  486. {
  487. int numItems = myDvdInv.getNumItems();
  488. if (numItems != 0)
  489. index = (--index) % numItems;
  490.  
  491. if (index < 0)
  492. index = numItems - 1;
  493.  
  494. if (numItems == 0) // catches for last entry not needed because we add a blank entry at zero but just in case
  495. JOptionPane.showMessageDialog(null, "That's the last entry.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
  496.  
  497. repaintGUI();
  498. }
  499.  
  500.  
  501. nextButton.addActionListener(new ActionListener() //goes to next entry on the list
  502. {
  503. public void actionPerformed(ActionEvent e)
  504. {
  505. int numItems = myDvdInv.getNumItems();
  506. index = (++index) % numItems; // moves index up one
  507. repaintGUI();
  508.  
  509.  
  510. }// end action
  511.  
  512. }); // end class
  513.  
  514. lastButton.addActionListener(new ActionListener()
  515. {
  516. public void actionPerformed(ActionEvent e)
  517. {
  518. int numItems = myDvdInv.getNumItems();
  519. index = (numItems -1) % numItems; //goes to first entry then minus one
  520. repaintGUI();
  521.  
  522. }// end action
  523.  
  524. }); // end clas
  525.  
  526. addButton.addActionListener(new ActionListener()
  527. {
  528.  
  529. public void actionPerformed(ActionEvent e)
  530. {
  531. FeeQtyProduct temp = (FeeQtyProduct) myDvdInv.getFeeQtyProduct(index);
  532. int numItems = myDvdInv.getNumItems() +1;
  533.  
  534. index = (numItems - 2) % numItems;
  535. repaintGUI();
  536.  
  537.  
  538. if(movieText.getText().equals("Add Movie Name" )) // catches for assigning more then one blank at a time
  539. {
  540. 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);
  541. }
  542.  
  543. if(movieText.getText().equals("Add Movie Name" ) !=true) // allows the adding of an entry
  544. {
  545. FeeQtyProduct product = new FeeQtyProduct( "Add Movie Name", Integer.parseInt(itemNumberText.getText()) + 1, 0, 0.0,0 );
  546. index = (numItems - 1) % numItems;
  547. myDvdInv.addFeeQtyProduct(product );
  548. repaintGUI();
  549. }
  550. if (numItems == 29) // catches for going over static inventory size
  551. {
  552. myDvdInv.removeFeeQtyProduct(temp);
  553. 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);
  554. }
  555.  
  556. }// end action
  557.  
  558. }); // end class
  559.  
  560. saveButton.addActionListener(new ActionListener() // saves the dat file in English
  561. {
  562. public void actionPerformed(ActionEvent e)
  563. {
  564. int numItems = myDvdInv.getNumItems();
  565. InventoryStorage record = new InventoryStorage(); //calls inventroy storage class
  566. record.openFile();
  567. int currentRecord = 0; // keeps track of number of cycles
  568.  
  569. do // cycles through the list adding them one at a time
  570. {
  571. record.addRecords();
  572. currentRecord = currentRecord + 1;
  573. index = (++index) % numItems;
  574.  
  575. } while (currentRecord < numItems); //ends while
  576.  
  577. record.closeFile(); //closes file
  578. }//end action
  579.  
  580. }); // end class
  581.  
  582. modifyButton.addActionListener(new ActionListener() // saves changes to the GUI
  583. {
  584.  
  585. public void actionPerformed(ActionEvent e)
  586. {
  587.  
  588. if (movieText.getText().equals("")) //traps for blank entry
  589. {
  590. JOptionPane.showMessageDialog(null, "Please Complete the Entry.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
  591. repaintGUI();
  592. }
  593.  
  594.  
  595. if (yearText.getText().equals("")) //traps for blank entry
  596. {
  597. JOptionPane.showMessageDialog(null, "Please Complete the Entry.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
  598. repaintGUI();
  599. }
  600.  
  601. try // traps for letters and blank entry
  602. {
  603.  
  604. Double.parseDouble(qtyText.getText());
  605. Double.parseDouble(priceText.getText());
  606.  
  607. }
  608. catch (Exception d)
  609. {
  610. JOptionPane.showMessageDialog(null, "Recheck Entry use numbers for price and quantity.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
  611. repaintGUI();
  612. }
  613.  
  614.  
  615. String name; int number; double amount, price; int year; // declares variables
  616.  
  617. name = yearText.getText();
  618. number = Integer.parseInt(itemNumberText.getText());
  619. amount = Double.parseDouble(qtyText.getText());
  620. price = Double.parseDouble(priceText.getText());
  621. year = Integer.parseInt(yearText.getText());
  622.  
  623.  
  624. FeeQtyProduct modify = (FeeQtyProduct) myDvdInv.getFeeQtyProduct(index);
  625.  
  626. modify.setProductNumber(number);
  627. modify.setProductName(name);
  628. modify.setBaseAmount(amount);
  629. modify.setBasePrice(price);
  630. modify.setProductYear(year);
  631. repaintGUI();
  632. }
  633.  
  634. }); // end class
  635.  
  636. deleteButton.addActionListener(new ActionListener() //allows user to delete entry and sorts product numbers to be in sequence
  637. {
  638. public void actionPerformed(ActionEvent e)
  639. {
  640.  
  641. int numItems = myDvdInv.getNumItems();
  642. FeeQtyProduct temp = (FeeQtyProduct) myDvdInv.getFeeQtyProduct(index);
  643.  
  644. if (numItems != 0)
  645. {
  646.  
  647. if(Integer.parseInt(itemNumberText.getText()) != numItems)
  648. {
  649.  
  650. myDvdInv.remove(index);
  651. repaintGUI();
  652. int i = Integer.parseInt(itemNumberText.getText());
  653. index = (++index) % numItems;
  654. repaintGUI();
  655. int j = Integer.parseInt(itemNumberText.getText());
  656.  
  657. if (i > j)// my own little sort mechanism to keep Product numbers in sequence
  658. index = (-- index) % numItems;
  659. repaintGUI();
  660. temp = (FeeQtyProduct) myDvdInv.getFeeQtyProduct(index);
  661. temp.setProductNumber(j-1);
  662. index = (++index) % numItems;
  663. repaintGUI();
  664.  
  665. }// end if
  666.  
  667. 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
  668. {
  669. myDvdInv.removeFeeQtyProduct(temp);
  670. index = (++index) % numItems;
  671. repaintGUI();
  672. }//end if
  673.  
  674. }// end if
  675.  
  676. if (numItems == 1) // catches for 0 items error
  677. {
  678.  
  679. FeeQtyProduct product = new FeeQtyProduct( "Add Movie Name",numItems, 0, 0.0,0);
  680. myDvdInv.addFeeQtyProduct(product);
  681. JOptionPane.showMessageDialog(null, "Delete Process Complete.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
  682. repaintGUI();
  683. } //end if
  684.  
  685.  
  686. }// end action
  687.  
  688.  
  689.  
  690. }); // end class
  691.  
  692. searchButton.addActionListener(new ActionListener()
  693. {
  694. public void actionPerformed(ActionEvent e)
  695. {
  696. //declare variables and gets text from GUI
  697. String search = searchText.getText();
  698. String name = movieText.getText();
  699. int number = Integer.parseInt(itemNumberText.getText());
  700. int numItems = myDvdInv.getNumItems();
  701. int currentRecord = 0;
  702.  
  703. do // gets text and checks for a match
  704. {
  705. index = (++index) % numItems;
  706. repaintGUI();
  707. name = movieText.getText();
  708. number = Integer.parseInt(itemNumberText.getText());
  709. search = searchText.getText();
  710. currentRecord = (++currentRecord);
  711.  
  712. if(name.equalsIgnoreCase( search )) // stops on item
  713. repaintGUI();
  714.  
  715. if(searchText.getText().equals("" )) //catches for no entry in the search box
  716. {
  717. JOptionPane.showMessageDialog(null, "What would you like to search for?","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
  718. index = (--index) % numItems;
  719. break;
  720. }
  721.  
  722. if(currentRecord == numItems +1) // displays message if no results match search
  723. {
  724. JOptionPane.showMessageDialog(null, "No Results Found","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
  725. break;
  726. }
  727.  
  728.  
  729. }while(name.equalsIgnoreCase(search ) != true); //ends do while
  730.  
  731.  
  732. }//end action
  733.  
  734.  
  735. }); // end class
  736. helpButton.addActionListener(new ActionListener() // this is basically to tell you what to do with the program
  737. {
  738. public void actionPerformed(ActionEvent e)
  739. {
  740. 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);
  741. repaintGUI();
  742. }
  743.  
  744. }); // end class
  745.  
  746.  
  747. } // end DvdInvGUI
  748. class InventoryStorage // creates the output file
  749. {
  750. private Formatter output; // object used to output text to file
  751.  
  752. public void openFile()
  753. {
  754. try
  755. {
  756. String strDirectoy ="C://data/";
  757.  
  758. // Create one directory
  759. boolean success = (new File(strDirectoy)).mkdir();
  760.  
  761. if (success)
  762. {
  763.  
  764. JOptionPane.showMessageDialog(null, "we had to create a directory named data in your C drive.","That's affirmative", JOptionPane.PLAIN_MESSAGE);
  765.  
  766. } //end if
  767.  
  768.  
  769. }//end try
  770.  
  771. catch (Exception e)
  772. {
  773.  
  774.  
  775. JOptionPane.showMessageDialog(null, "You do not have write access to the C: drive.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
  776.  
  777. }//end catch
  778.  
  779.  
  780.  
  781. try
  782. {
  783.  
  784. output = new Formatter( "C:/data/inventory.dat");
  785.  
  786. } // end try
  787.  
  788. catch ( SecurityException securityException ) //catches for write access and exits program
  789. {
  790. JOptionPane.showMessageDialog(null, "You do not have write access to this file.","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
  791. System.exit( 1 );
  792.  
  793. } // end catch
  794.  
  795. catch ( FileNotFoundException filesNotFoundException ) //catches for write access and exits program
  796. {
  797. JOptionPane.showMessageDialog(null, "Please create a file named data in your c drive","Negative GhostRider the pattern is full", JOptionPane.ERROR_MESSAGE);
  798. System.exit( 1 );
  799.  
  800. } // end catch
  801.  
  802.  
  803. JOptionPane.showMessageDialog(null, "file saved successfully.","That's affirmative", JOptionPane.PLAIN_MESSAGE);
  804.  
  805.  
  806.  
  807. } // end method openFile
  808. public void addRecords() // adds the records to the file
  809. {
  810.  
  811. FeeQtyProduct record = (FeeQtyProduct) myDvdInv.getFeeQtyProduct(index);
  812.  
  813. // rounds the output numbers to 2 decimals
  814.  
  815. BigDecimal roundPrice = new BigDecimal(Double.toString(record.restock() ));
  816. roundPrice = roundPrice.setScale(2, RoundingMode.HALF_UP);
  817.  
  818. BigDecimal roundValue= new BigDecimal(Double.toString(record.total()));
  819. roundValue= roundValue.setScale(2, RoundingMode.HALF_UP);
  820.  
  821. BigDecimal roundTotal= new BigDecimal(Double.toString(myDvdInv.value()));
  822. roundTotal = roundTotal.setScale(2, RoundingMode.HALF_UP);
  823.  
  824.  
  825. if (record != null) //catches for blank record - overkill because we can never have a blank record
  826. {
  827. output.format( "Artist:%s Product#: %s QTY#:%.0f Price: $%.2f%s: %s" ,
  828. record.getProductName(), record.getProductNumber(), record.getBaseAmount(), record.getBasePrice(), record.getProductYear()() ,
  829. " with restock Fee $" + (roundPrice) + " value: $" + (roundValue) + " Inventory Total $" + (roundTotal) + "\t\n END OF LINE\t\t");
  830.  
  831. } // end if
  832. } // end addRecords
  833.  
  834. public void closeFile() // close the file
  835. {
  836. if ( output != null )
  837. output.close();
  838.  
  839. } // end method closeFile
  840.  
  841. }// end InventoryStorage class
  842.  
  843.  
  844. // display GUI
  845. public void repaintGUI()
  846. {
  847.  
  848. FeeQtyProduct temp = (FeeQtyProduct) myDvdInv.getFeeQtyProduct(index);
  849.  
  850. if(temp != null) //catches for no entries
  851. {
  852. itemNumberText.setText("" + temp.getProductNumber());
  853. movieText.setText(temp.getProductName());
  854. yearText.setText(String.format("%s", temp.getProductYear()));
  855. priceText.setText(String.format("%.2f", temp.getBasePrice()));
  856. restockFeeText.setText(String.format("$%.2f", temp.restock()));
  857. qtyText.setText(String.format("%.0f",temp.getBaseAmount()));
  858. valueText.setText(String.format("$%.2f", temp.total()));
  859.  
  860.  
  861. }// end if
  862. totalValueText.setText(String.format("$%.2f", myDvdInv.value()));
  863.  
  864. } // end repaintGUI
  865.  
  866. } // End InventoryGUI class
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,190
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 483
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer

Re: Please help Errors will not compile

 
-1
  #2
Aug 15th, 2008
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.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC