I have written some code for an Inventory program that I am working on for a Java Class. I keep getting the cannot find symbol error. I have been trying to fix it and can not. Some simple guidence would be nice. Here is what I have already with errors on line 10, 21, 22, 23, 24, and 27.

// inventory program part4
// by Jason Waldrop

import javax.swing.*;

import java.awt.event.*;
public class Inventory4 extends JFrame {
	
	private JTextArea text;
	private Inventory inv;
	private int view;
	
	
	public Inventory4() {
		
		super("DVD");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // If the window is to be closed then it quits
		view = 0; // Current viewing
		
		// my products		
		DVD p1 = new DVD(1,"Superbad",3,15.49);
		DVD p2 = new DVD(2,"Full Metal Jacket",7,17.29);
		DVD p3 = new DVD(3,"Transformers",5,19.99);
		DVD p4 = new ExtendedDVD(3,"Shawshank Redemption",5,14.99,"Frank Darabont");
	
		//My inventory entered in:
		inv = new Inventory(3);
		inv.add(p1);
		inv.add(p2);
		inv.add(p3);
		inv.add(p4);
		
		// output the products
		inv.view();
		
		//My Graphical User Interface
		JPanel panel = new JPanel();
		panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
		text = new JTextArea(20,50);
		text.setEditable(false);
		panel.add(text);
		showDVD();

		JButton next = new JButton("Next");
		next.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (view < inv.size()-1) view++;
				else view = 0; 
				showDVD();
			}
		});
		panel.add(next);
		

		getContentPane().add(panel);
		
	}
	
	// This is where we view the DVD
	public void showDVD() {
		text.setText("DVD Details:\n");
		text.append(inv.get(view).toString()+"\n");
		text.append(String.format
				("The value of all my Dvds: $%.2f", inv.value()));
	}

	public static void main(String args [])
	{
		Inventory4 invt = new Inventory4();
		invt.pack();
		invt.setVisible(true);
		
	} //end main
}

Recommended Answers

All 5 Replies

Put your code in code tags so that we can see what line numbers those are.

What the heck is code tags?

I have written some code for an Inventory program that I am working on for a Java Class. I keep getting the cannot find symbol error. I have been trying to fix it and can not. Some simple guidence would be nice. Here is what I have already with errors on line 10, 21, 22, 23, 24, and 27.


[// inventory program part4]
[// by Jason Waldrop]

[import javax.swing.*;]

[import java.awt.event.*;]
[public class Inventory4 extends JFrame {]

private JTextArea text;]
[private Inventory inv;]
[private int view;]


[public Inventory4() {]

[super("DVD");]
[setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // If the ][window is to be closed then it quits]
[view = 0; // Current viewing]

[// my products ]
[DVD p1 = new DVD(1,"Superbad",3,15.49);]
[DVD p2 = new DVD(2,"Full Metal Jacket",7,17.29);]
[DVD p3 = new DVD(3,"Transformers",5,19.99);]
[DVD p4 = new ExtendedDVD(3,"Shawshank Redemption",5,14.99,"Frank Darabont");]

[//My inventory entered in:]
[inv = new Inventory(3);]
[inv.add(p1);]
[inv.add(p2);]
inv.add(p3);]
[inv.add(p4);]

[// output the products]
[inv.view();]

[//My Graphical User Interface]
[JPanel panel = new JPanel();]
[panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));]
[text = new JTextArea(20,50);]
[text.setEditable(false);]
[panel.add(text);]
[showDVD();]

[JButton next = new JButton("Next");]
[next.addActionListener(new ActionListener() {]
[public void actionPerformed(ActionEvent e) {]
[if (view < inv.size()-1) view++;]
[else view = 0;]
[showDVD();]
[}]
[});]
[panel.add(next);]


[getContentPane().add(panel);]

[}]

[// This is where we view the DVD]
[public void showDVD() {]
[text.setText("DVD Details:\n");]
[text.append(inv.get(view).toString()+"\n");]
[text.append(String.format]
[("The value of all my Dvds: $%.2f", inv.value()));]
[}]

[public static void main(String args [])]
[{]
[Inventory4 invt = new Inventory4();]
[invt.pack();]
[invt.setVisible(true);]

[} //end main]
[}]

What the heck is code tags?

Wrap your code in [code] tags like Tekmaven did when he edited your post. See how it's easier to read?

Code tags:

[code]
paste code here
[/code]

or

[code=JAVA]
paste code here
[/code]

There are other classes that you haven't posted so we can't run it. There is no line 10, at least with the code tags that Tekmaven added, so please repost with code tags:

[code=JAVA]
paste code here
[/code]

and point out the exact lines of the errors as well as the exact error messages.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.