2 Replies - 5575 Views - Last Post: 24 January 2009 - 11:36 AM Rate Topic: -----

#1 edgeofthorns  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 18-December 08

Inventory program part 6

Post icon  Posted 23 January 2009 - 09:15 PM

Modify the Inventory Program to include an Add button, a Delete button, and a Modify
button on the GUI. These buttons should allow the user to perform the corresponding
actions on the item name, the number of units in stock, and the price of each unit. An
item added to the inventory should have an item number one more than the previous last
item.
· Add a Save button to the GUI that saves the inventory to a C:\data\inventory.dat file.
· Use exception handling to create the directory and file if necessary.
· Add a search button to the GUI that allows the user to search for an item in the inventory
by the product name. If the product is not found, the GUI should display an appropriate
message. If the product is found, the GUI should display that product’s information in the
GUI.

I am having compiling problems.I have multiple errors between lines 268 to 541. Could someone take a look at what I have and maybe give me some pointers on what can be done to get this program working? Thank you all


// Week 9 Final Project - Inventory6
// Richard Fondy
// IT/215 - Java Programming
// Inventory6.java
// January 25th, 2009


import java.util.Arrays;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.io.*;


class GUI extends JFrame {
	// place to store all the DVDs in the inventory
	private Inventory inventory;

	// index of the DVD displaying on the screen
	private int index = 0;

	// GUI elements to display currently selected DVDs	 

information
	private JLabel prodNameLabel = new JLabel("Product Name: 

");
	private JTextField prodNameText;

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

	private JLabel genreLabel = new JLabel("Genre: ");
	private JTextField genreText;

	private JLabel prodPriceLabel = new JLabel("Price: ");
	private JTextField prodPriceText;

	private JLabel quantityLabel = new JLabel("Quantity: ");
	private JTextField quantityText;

	private JLabel valueLabel = new JLabel("Inventory Value: 

");
	private JTextField valueText;

	private JLabel restockingFeeLabel = new JLabel

("Restocking Fee (5%): ");
	JTextField restockingFeeText;

	private JLabel totalValueLabel = new JLabel("Inventory 

Total: ");
	private JTextField totalValueText;

	public GUI(Inventory inventory) {
		super("Richard's Inventory6");
		final Dimension dim = new Dimension(140, 30);
		final FlowLayout flo = new FlowLayout

(FlowLayout.LEFT);
		JPanel jp;

		//create inventory object to hold products
		this.inventory = inventory;

		//setup panel for all component information
		JPanel centerPanel = new JPanel();
		centerPanel.setLayout(new BoxLayout(centerPanel, 

BoxLayout.Y_AXIS));

		JPanel buttonPanel = new JPanel();
		JButton nextButton = new JButton("Next");
		nextButton.addActionListener(new NextButtonHandler

());
		buttonPanel.add(nextButton);
		centerPanel.add(buttonPanel);

		jp = new JPanel(flo);
		itemNumberLabel.setPreferredSize(dim);
		jp.add(itemNumberLabel);
		itemNumberText = new JTextField(3);
		itemNumberText.setEditable(false);
		jp.add(itemNumberText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		prodNameLabel.setPreferredSize(dim);
		jp.add(prodNameLabel);
		prodNameText = new JTextField(17);
		prodNameText.setEditable(false);
		jp.add(prodNameText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		prodPriceLabel.setPreferredSize(dim);
		jp.add(prodPriceLabel);
		prodPriceText = new JTextField(17);
		prodPriceText.setEditable(false);
		jp.add(prodPriceText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		quantityLabel.setPreferredSize(dim);
		jp.add(quantityLabel);
		quantityText = new JTextField(5);
		quantityText.setEditable(false);
		jp.add(quantityText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		restockingFeeLabel.setPreferredSize(dim);
		jp.add(restockingFeeLabel);
		restockingFeeText = new JTextField(17);
		restockingFeeText.setEditable(false);
		jp.add(restockingFeeText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		valueLabel.setPreferredSize(dim);
		jp.add(valueLabel);
		valueText = new JTextField(17);
		valueText.setEditable(false);
		jp.add(valueText);
		centerPanel.add(jp);

		//add all inventory to the panel
		jp = new JPanel(flo);
		totalValueLabel.setPreferredSize(dim);
		jp.add(totalValueLabel);
		totalValueText = new JTextField(17);
		totalValueText.setEditable(false);
		jp.add(totalValueText);
		centerPanel.add(jp);

		centerPanel.add(genreLabel);
		genreText = new JTextField("");
		genreText.setEditable(false);
		centerPanel.add(genreText);

		centerPanel.add(prodNameLabel);
		prodNameText = new JTextField("");
		prodNameText.setEditable(false);
		centerPanel.add(prodNameText);

		centerPanel.add(itemNumberLabel);
		itemNumberText = new JTextField("");
		itemNumberText.setEditable(false);
		centerPanel.add(itemNumberText);

		centerPanel.add(quantityLabel);
		quantityText = new JTextField("");
		quantityText.setEditable(false);
		centerPanel.add(quantityText);

		centerPanel.add(prodPriceLabel);
		prodPriceText = new JTextField("");
		prodPriceText.setEditable(false);
		centerPanel.add(prodPriceText);

		centerPanel.add(restockingFeeLabel);
		restockingFeeText = new JTextField("");
		restockingFeeText.setEditable(false);
		centerPanel.add(restockingFeeText);

		centerPanel.add(valueLabel);
		valueText = new JTextField("");
		valueText.setEditable(false);
		centerPanel.add(valueText);

		// inventory information
		centerPanel.add(totalValueLabel);
		totalValueText = new JTextField("");
		centerPanel.add(totalValueText);

		// Set up the GUI's button(s)
		JButton btnNext = new JButton("Next");
		btnNext.addActionListener(new NextButtonHandler());
		centerPanel.add(btnNext);

		JButton btnPrevious = new JButton("Previous");
		btnPrevious.addActionListener(new				 

PreviousButtonHandler());
		centerPanel.add(btnPrevious);

		JButton btnFirst = new JButton("First");
		btnFirst.addActionListener(new FirstButtonHandler

());
		centerPanel.add(btnFirst);

		JButton btnLast = new JButton("Last");
		btnLast.addActionListener(new LastButtonHandler ());
		centerPanel.add(btnLast);

		///Add panel to GUI
		setContentPane(centerPanel);

		repaintGUI();

		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(650, 850);
		setContentPane(centerPanel);
		setResizable(false);
		setLocationRelativeTo(null);
		setVisible(true);
	}

	// refresh all the information displayed in the GUI to 

show the currently selected DVD

	public void repaintGUI() {
		Movie temp = (Movie) inventory.getDVD(index);

		if (temp != null) {
			itemNumberText.setText("" + temp.getDvdItem());
			prodNameText.setText(temp.getDvdTitle());
			prodPriceText.setText(String.format("$%.2f", 

temp.getDvdPrice()));
			restockingFeeText.setText(String.format("$%.2f", 

temp.restockingFee()));
			quantityText.setText("" + temp.getDvdStock());
			valueText.setText(String.format("$%.2f", 

temp.value()));
		}
		totalValueText.setText(String.format("$%.2f", 

inventory.entireValue()));
	}

	/**
	*  Handle the button/s
	**/

	class NextButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			int numItems = inventory.getNumDVDs();
			index = (++index) % numItems;

			repaintGUI();
		}
	} // end NextButtonHandler class

	class PreviousButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			int numItems = inventory.getNumDVDs();
			if (numItems != 0)
				index = (--index) % numItems;

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

			if (numItems == 0) // catches for last entry
				JOptionPane.showMessageDialog(null, "End of 

all entries.",
											  "Negative 

pattern is full",
											  

JOptionPane.ERROR_MESSAGE);
			repaintGUI();
		}
	} // end PreviousButtonHandler class

	class FirstButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			index = 0;
			repaintGUI();
		}
	} // end FirstButtonHandler class

	class LastButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			int numItems = inventory.getNumDVDs();
			index = (numItems -1) % numItems;
			repaintGUI();
		}
	} // end LastButtonHandler class

	class NextButtonHandler2 implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			int numItems = inventory.getNumDVDs();
			index = (++index) % numItems;
			repaintGUI();
		}
	} // end NextButtonHandler class

	class AddButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {
	
			Inventory temp = (Inventory)
								 inventory.getInventory 

(index);
			int numItems = inventory.getNumDvds() +1;

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

			if (movieText.getText().equals("Add Movie Name" 

)) //  for assigning more then one blank at a time
			{
				JOptionPane.showMessageDialog(null, "Please 

add to blank entry you already have before adding 

more\nRemember: Click Modify when changes are 

done","Negative the pattern is full", 

JOptionPane.ERROR_MESSAGE);
			}

			if (movieText.getText().equals("Add Movie Name" 

) !=true) // allows the adding of an entry
			{
				Inventory dvd = new Inventory( "Add Movie 

Name", Integer.parseInt(itemNumberText.getText()) + 1, 0, 

0.0, "Add Genre Type");
				index = (numItems - 1) % numItems;
				inventory.addToInventory(dvd);
				repaintGUI();
			}
			if (numItems == 24) // stops for going over 

inventory size
			{
				inventory.removeInventory(temp);
				JOptionPane.showMessageDialog(null, "Do Not 

Add No More Entries\n You can increase total space in the 

java file Inventory6.","Negative the pattern is full", 

JOptionPane.ERROR_MESSAGE);
			}

		}// end action

	} // end class

	class SaveButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			int numItems = inventory.getNumDVDs();
			InventoryStorage record = new InventoryStorage

(); //calls inventory storage class
			record.openFile();
			int currentRecord = 0; // keeps track of number 

of cycles

			do // goes through the list adding entries 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

	class ModifyButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {


			if (dvdText.getText().equals(""))  //traps for 

blank entry
			{
				JOptionPane.showMessageDialog(null, "Please 

Finish the Entry.","Negative the pattern is full", 

JOptionPane.ERROR_MESSAGE);
				repaintGUI();
			}

			if (genreText.getText().equals(""))  //for blank 

entry
			{
				JOptionPane.showMessageDialog(null, "Please 

Finish the Entry.","Negative the pattern is full", 

JOptionPane.ERROR_MESSAGE);
				repaintGUI();
			}

			try // traps for letters and blank entry
			{
				Double.parseDouble(stockText.getText());
				Double.parseDouble(priceText.getText());

			} catch (Exception d) {
				JOptionPane.showMessageDialog(null, "Recheck 

Entry use numbers for price and quantity.","Negative the 

pattern is full", JOptionPane.ERROR_MESSAGE);
				repaintGUI();
			}

			String title;
			int stock;
			double price;
			String genre; // declares variables

			title = dvdText.getText();
			stock = Integer.parseInt(stockText.getText());
			price = Double.parseDouble(priceText.getText());
			genre = genreText.getText();

			Inventory modify =  (Inventory)				  

	   inventory.getInventory(index);

			modify.setdvdTitle(title);
			modify.setdvdGenre(genre);
			modify.setdvdStock(stock);
			modify.setdvdPrice(price);

			repaintGUI();

		}

	} // end class

	class DeleteButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {	

			int numItems = inventory.getNumItems();
			Inventory temp = (Inventory)					 

	inventory.getInventory(index);

			if (numItems != 0) {

				if (Integer.parseInt(itemNumberText.getText

()) != numItems) {

					inventory.remove(index);
					repaintGUI();
					int i = Integer.parseInt

(itemNumberText.getText());
					index = (++index) % numItems;
					repaintGUI();
					int j = Integer.parseInt

(itemNumberText.getText());

					if (i > j)// added sort mechanism to 

keep Dvds in sequence
						index = (-- index) % numItems;
					repaintGUI();
					temp = (Inventory) 

inventory.getInventory(index);
					temp.setDvdNumber(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 added
				{
					inventory.removeInventory(temp);
					index = (++index) % numItems;
					repaintGUI();
				}//end if

			}// end if

			if (numItems == 1) // stops 0 items error
			{
				Inventory dvd = new Inventory( "Add Movie 

Name",numItems, 0, 0.0, "Add Movie Genre");
				inventory.addToInventory(dvd);
				JOptionPane.showMessageDialog(null, 

"Deletion Complete.","Negative the pattern is full", 

JOptionPane.ERROR_MESSAGE);
				repaintGUI();
			} //end if


		}// end action

	} // end class

	class SearchButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {
	

			int numItems = inventory.getNumItems();
			Inventory temp = (Inventory) 

inventory.getInventory(index);

			if (numItems != 0) {

				if (Integer.parseInt(itemNumberText.getText

()) != numItems) {

					inventory.remove(index);
					repaintGUI();
					int i = Integer.parseInt

(itemNumberText.getText());
					index = (++index) % numItems;
					repaintGUI();
					int j = Integer.parseInt

(itemNumberText.getText());

					if (i > j)// sort mechanism to keep 

DVD's in sequence
						index = (-- index) % numItems;
					repaintGUI();
					temp = (Inventory)					 

inventory.getInventory(index);
					temp.setDvdNumber(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 added
				{
					inventory.removeInventory(temp);
					index = (++index) % numItems;
					repaintGUI();
				}//end if

			}// end if

			if (numItems == 1) // catches for 0 items error
			{

				Inventory dvd = new Inventory( "Add Movie 

Name",numItems, 0, 0.0, "Add Movie Genre");
				inventory.addToInventory(dvd);
				JOptionPane.showMessageDialog(null, 

"Deletion Complete.","Negative the pattern is full", 

JOptionPane.ERROR_MESSAGE);
				repaintGUI();
			} //end if


		}// end action

	} // end class

} // end class GUI



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,
											  " a directory 

named data has been created in your C drive.",
											  "Message",
											  

JOptionPane.PLAIN_MESSAGE);
			}   //end if

		}//end try

		catch (Exception e) {
			JOptionPane.showMessageDialog(null,
										  "You do not have 

write access to the C: drive.",
										  "Negative 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 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 the 

pattern is full", JOptionPane.ERROR_MESSAGE);
			System.exit( 1 );
		} // end catch

		JOptionPane.showMessageDialog(null, "file saved 

successfully.",
									  "That's confirmed", 

JOptionPane.PLAIN_MESSAGE);

	} // end method openFile

	public void addRecords() // adds the records to the file
	{

		Inventory record = (Inventory)		  

inventory.getInventory(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(inventory.value()));
		roundTotal = roundTotal.setScale(2, 

RoundingMode.HALF_UP);

		if (record != null) //catches for blank record
		{
			output.format( "item=%03d   title=%-20s  

units=%3d   price= $%6.2f   value= $%7.2f" ,
						   record.getDvdName(), 

record.getDvdNumber(), record.getDvdAmount(), 

record.getDvdPrice() ,
						   " DVD", record.getDVDTitle() + "  

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


//adds a logo
class ArcsJPanel extends JPanel {

	public void paintComponent( Graphics g ) {
		super.paintComponent( g ); // call	superclass's 

paintComponent

		// draws larger 3d rectangle
		g.setColor( Color.BLUE );
		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.BLUE );
		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( "Ricks DVD's", 10, 45 );

	} // end method paintComponent

}


public class Inventory6 {

	public static void main(String[] args) {

		DVD dvd;
		Inventory inventory = new Inventory();

		System.out.println("\nCheckPoint: Inventory Part 6

\n");

		dvd = new Movie(01, "No Country For Old Men", 1, 

10.49f, "Drama");
		inventory.addToInventory(dvd);

		dvd = new Movie(14, "Cloverfield", 2, 9.99f, 

"Action");
		inventory.addToInventory(dvd);

		dvd = new DVD(36, "Spiderman 3", 10, 6.89f);
		inventory.addToInventory(dvd);

		dvd = new DVD(04, "The Mist", 6, 5.75f);
		inventory.addToInventory(dvd);

		inventory.display();
		System.out.println("\nEnd of Inventory, have a good 

day!\n");

		new GUI(inventory);
	} //end main

} // end class Inventory4


class DVD  {

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

	public DVD(int item, String title, int stock, double 

price) {
		dvdItem  = item;
		dvdTitle = title;
		dvdStock = stock;
		dvdPrice = price;
	} //end four-argument constructor

	// set DVD Item
	public void setDvdItem(int item) {
		dvdItem = item;
	} //end method  set Dvd Item

	//return DVD Item
	public int getDvdItem() {
		return dvdItem;
	} //end method get Dvd Item

	//set DVD Title
	public void setDvdTitle(String title) {
		dvdTitle = title;
	} //end method set Dvd Title

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

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

	//return dvd Stock
	public int getDvdStock() {
		return dvdStock;
	} //end method get Dvd Stock

	public void setDvdPrice(double price) {
		dvdPrice = price;
	} //end method setdvdPrice

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

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

	public String toString() {
		return String.format("item=%03d   title=%-20s   

units=%3d   price= $%6.2f   value= $%7.2f",
							 dvdItem, dvdTitle, dvdStock, 

dvdPrice, value());
	}

} //end class DVD



class Inventory {

	private DVD[] dvds;
	private int numDVDs;

	Inventory() {
		dvds = new DVD[25];
		numDVDs = 0;
	}

	// Add DVD into Inventory end.Sort array by title
	public void addToInventory(DVD dvd) {
		dvds[numDVDs] = dvd;
		++numDVDs;
		sort();
	}

	public int getNumDVDs() {
		return numDVDs;
	}

	public DVD getDVD(int n) {
		return dvds[n];
	}

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

	public void sort() {
		for (int index = 1; index < numDVDs; index++) {
			DVD key = dvds[index];
			int position = index;

			//  Shift larger values to the right
			while (position > 0 && key.getDvdTitle

().compareTo(dvds[position-1].getDvdTitle()) < 0) {
				dvds[position] = dvds[position-1];
				position--;
			}
			dvds[position] = key;
		}
	}

	public void display() {
		System.out.println("\nThe inventory contains " + 

numDVDs + " DVDs\n");
		for (int i = 0; i < numDVDs; i++)
			System.out.printf("%3d  %s\n", i, dvds[i]);
		System.out.printf("\nThe total inventory value is $

%.2f\n\n", entireValue());
	}

} // end class Inventory




class Movie extends DVD {

	private String genre;

	Movie(int item, String title, int stock, double price, 

String genre) {
		// calling the parent class
		super(item, title, stock, price);
		// setting the cost of restocking the item
		this.genre = genre;
	}

	public String getGenre() {
		return genre;
	}

	public double restockingFee() {
		return super.value() * 0.05;
	}

	public double value() {
		double value = getDvdPrice() * getDvdStock();
		value = 1.05 * value;
		return value;
	} // end method value

	// Returns the price of a program
	// This is calculated by adding the cost of restocking 

it onto the actual price
	public String toString() {
		String s = String.format("genre=%-12s", genre);
		s = s + " " + super.toString();
		return s;
	}

} // end class Movie

[code]

Is This A Good Question/Topic? 0
  • +

Replies To: Inventory program part 6

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Inventory program part 6

Posted 23 January 2009 - 09:49 PM

Ouf... hope you don't expect us to pass through your 960 lines of code ?

OK around line 268 here are where the problem starts:

	class AddButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {

			Inventory temp = (Inventory) inventory.getInventory(index);
			int numItems = inventory.getNumDvds() +1;


The Inventory class does not have a method getInventory(int) neither a method getNumDVDs()

The error is repeated in many of your ActionListener

			if (movieText.getText().equals("Add Movie Name" )) //  for assigning more then one blank at a time
			{
				JOptionPane.showMessageDialog(null, "Please add to blank entry you already have before adding more\nRemember: Click Modify when changes are done","Negative the pattern is full", 

						JOptionPane.ERROR_MESSAGE);
			}

			if (movieText.getText().equals("Add Movie Name") !=true) // allows the adding of an entry
			{
				Inventory dvd = new Inventory( "Add Movie Name", Integer.parseInt(itemNumberText.getText()) + 1, 0, 0.0, "Add Genre Type");
				index = (numItems - 1) % numItems;
				inventory.addToInventory(dvd);


movieText is an undefined variable
Inventory does not have a constructor expecting as arguments(String, int, int, double, String)
BTW after calling an OptionPane no need to repaint your GUI. Java will do it for you

		inventory.removeInventory(temp);


Inventory does not have a method removeInventory(Inventory);

	class ModifyButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {


			if (dvdText.getText().equals(""))  //traps for blank entry


dvdText is not defined... looks a lot like the movieText that was not defined a little bit earlier

			try // traps for letters and blank entry
			{
				Double.parseDouble(stockText.getText());
				Double.parseDouble(priceText.getText());

			} catch (Exception d) {


stockText is not defined.... you seem to have problems with variables ending by "Text" :D

			modify.setdvdTitle(title);
			modify.setdvdGenre(genre);
			modify.setdvdStock(stock);
			modify.setdvdPrice(price);


neither of these setdvdXXX methods are defined for Inventory... modify is aa Inventory object

OK that should keep you busy for a while...

I can't figure out how you can come whith so many errors
Usually you add 20 lines to a program and test it
than add another 20 and test it

You cut & paste this code from somewhere else or what ? Don't try to let beleive that you produce 500 lines of code without testing them :angry:
Was This Post Helpful? 0
  • +
  • -

#3 edgeofthorns  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 18-December 08

Re: Inventory program part 6

Posted 24 January 2009 - 11:36 AM

Yes that should keep me busy for a bit, Thank you very much for your input. Ive struggled through this class, I just need to learn to try and compile more often like you mentioned. Thank you once again :^:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1