954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Errors in Java

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
}
srrjason
Newbie Poster
3 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

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

BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
 

What the heck is code tags?

srrjason
Newbie Poster
3 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

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]
[}]

srrjason
Newbie Poster
3 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 
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?

cscgal
The Queen of DaniWeb
Administrator
19,424 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
 

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.

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You