Results 1 to 3 of 3
  1. #1
    Exether is offline Member
    Join Date
    Jul 2010
    Posts
    11
    Rep Power
    0

    Default Help with inventory program part 5 PLEASE!

    Hey I am very close to getting this to run but I am getting the error code:

    Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
    symbol: class Inventory
    location: class Inventory500
    at Inventory500.<init>(Inventory500.java:15)
    at Inventory500.main(Inventory500.java:99)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 2 seconds)

    It says the error is on line 15 with inventory!

    PHP Code:
    import javax.swing.*;
    
    import java.awt.event.*;
    import java.util.*;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    
    import javax.swing.JPanel;
    
    
    public class Inventory500 extends JFrame {
    
    	private JTextArea txt;
    	private Inventory inv;
    	private int currentDisplay = 0;
    	
    	public Inventory500() {
    		super("Game");
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    		init();
    	}
    	
    	public void init() {
    		
    		Game p1 = new Game (1, "Final Fantasy 7", 3, 17.99, "Rpg");
    	        Game p2 = new Game(2, "Modern Warfare 2", 1, 59.99, "Shooter");
    		Game p3 = new Game(3, "Street Fighter 4", 4, 29.99, "Fighter");
                    Game p4 = new Game(4, "Halo Reach",9, 59.99, "Shooter");
    		
    		inv = new Inventory();
    		inv.add(p1);
    		inv.add(p2);
    		inv.add(p3);
    		inv.add(p4);
    		inv.sort();
    
    
    		for (int i = 0; i < inv.size(); i++) {
    			System.out.println("Game number: " + inv.get(i).getitem());
    			System.out.println("Game name: " + inv.get(i).getName());
    			System.out.println("Games in stock: " + inv.get(i).getunits());
    			System.out.println("Price: $" + String.format("%.2f",inv.get(i).getprice()));
    			System.out.println("Total value: $" + String.format("%.2f",inv.get(i).value()));
    			System.out.println("Fee: $" + String.format("%.2f",inv.get(i).fee()));
    			System.out.println();
    		}
    
    		
    		System.out.println("Total value: $" + String.format("%.2f",inv.value()));
    		
    		
    		JPanel panel = new JPanel();
    		txt = new JTextArea(15,40);
    		txt.setEditable(false);
    		panel.add(txt);
    		
    		JButton first = new JButton("First");
    		first.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				currentDisplay = 0;
    				displaygames();
    			}
    		});
    		panel.add(first);
    		JButton previous = new JButton("Previous");
    		previous.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				if (currentDisplay > 0) currentDisplay--;
    				else currentDisplay = inv.size()-1;
    				displaygames();
    			}
    		});
    		panel.add(previous);
    		JButton next = new JButton("Next");
    		next.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				if (currentDisplay < inv.size()-1) currentDisplay++; 
    				else currentDisplay = 0;
    				displaygames();
    			}
    		});
    		panel.add(next);
    		JButton last = new JButton("Last");
    		last.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				currentDisplay = inv.size()-1;
    				displaygames();
    			}
    		});
    		panel.add(last);
    		panel.add(new Logo());
    		
    		getContentPane().add(panel);
    		
    		displaygames();
    	}
    	public static void main(String args[]) {
    		Inventory500 gui = new Inventory500();
    		gui.pack();
    		gui.setVisible(true);
    	}
    		
    
    	public void displaygames() {
    		txt.setText("Game Details:\n");
    		txt.append("Game number: " + inv.get(currentDisplay).getItem() + "\n");
    		txt.append("Game name: " + inv.get(currentDisplay).getName() + "\n");
    		txt.append("Games in stock: " + inv.get(currentDisplay).getUnits() + "\n");
    		txt.append("Price: $" + String.format("%.2f",inv.get(currentDisplay).getPrice()) + "\n");
    		txt.append("Total value: $" + String.format("%.2f",inv.get(currentDisplay).value()) + "\n");
    		txt.append("Fee: $" + String.format("%.2f",inv.get(currentDisplay).fee()) + "\n\n");
    	
    		txt.append("Total value: $" + String.format("%.2f",inv.value()));
    
    	}
    	
    	
    }
         class games {
    	private int item;
    	private String name;
    	private int units;
    	private double price;
    
    	public games(int item, String name, int units, double price) {
    		this.item = item;
    		this.name = name;
    		this.units = units;
    		this.price = price;
    	}
    
    	public double value() {
    		return units*price;
    	}
    
    	public int getItem() {
    		return item;
    	}
    
    	public void setItem(int item) {
    		this.item = item;
    	}
    
    	public String getName() {
    		return name;
    	}
    	public void setName(String name) {
    		this.name = name;
    	}
    
    	public int getUnits() {
    		return units;
    	}
    
    	public void setUnits(int units) {
    		this.units = units;
    	}
    
    	public double getPrice() {
    		return price;
    	}
    
    	public void setPrice(double price) {
    		this.price = price;
    	}
    
    
    
            class Inventory {
    	private ArrayList<Game> gamelist;
    
    	public Inventory() {
    		gamelist = new ArrayList<Game>();
    	}
    
    	
    
    	public void add(Game p) {
    		gamelist.add(p);
    	}
    
    	public Game get(int i) {
    		return gamelist.get(i);
    	}
    
    	public int size() {
    		return gamelist.size();
    	}
    
    	public void sort() {
    		
    		int n = gamelist.size();
    		for (int search = 1; search < n; search++) {
    			for (int i = 0; i < n-search; i++) {
    				if (gamelist.get(i).getName().compareToIgnoreCase(gamelist.get(i+1).getName()) > 0) {
    					
    					Game temp = gamelist.get(i);
    					gamelist.set(i,gamelist.get(i+1));
    					gamelist.set(i+1,temp);
    				}
    			}
    		}
    	}
    	
    	public double value() {
    		double total = 0.0;
    		for (int i = 0; i < gamelist.size(); i++) {
    			total += get(i).value();
    		}
    		return total;
    	}
    }
          class Logo extends JPanel {
    	public Logo() {
    		super();
    		setPreferredSize(new Dimension(200,200));
    	}
    	public void paint(Graphics g) {
    		g.setColor(Color.blue);
    		g.fillRoundRect(60,60,110,90,5,5);
    		g.setColor(Color.green);
    		g.drawString("Game Store", 75, 100);
    	}
    }
          class Game extends games {
    	
    	private String gstud = "";
    	
    	public Game(int item, String name, int units, double price, String studio) {
    		super(item, name, units, price);
    		this.gstud = studio;
              }
    
    	public String getStudio() {
    		return gstud;
    	}
    
    	public void setStudio(String gstud) {
    		this.gstud = gstud;
    	}
    	
    
    	public double value() {
    		return  1.05*getUnits()*getPrice();
    	}
    	
    
    	public double fee() {
    		return 0.05*getUnits()*getPrice();
    	}
    
    
        }
    }
    Last edited by Exether; 08-09-2010 at 04:28 AM.

  2. #2
    Exether is offline Member
    Join Date
    Jul 2010
    Posts
    11
    Rep Power
    0

    Default

    Reposted corrrectly.
    Last edited by Exether; 08-09-2010 at 04:28 AM.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,240
    Rep Power
    19

    Default

    Quote Originally Posted by Exether View Post
    Hey I am very close to getting this to run but I am getting the error code:

    Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
    symbol: class Inventory
    location: class Inventory500
    at Inventory500.<init>(Inventory500.java:15)
    So look at line 15 of Inventory500.java.

    db

Similar Threads

  1. Inventory Program Part 2 of 6
    By tlouvierre in forum New To Java
    Replies: 2
    Last Post: 05-28-2009, 01:30 AM
  2. Inventory Program Part 3 ~ please help!
    By marMcD in forum New To Java
    Replies: 13
    Last Post: 02-25-2009, 05:57 AM
  3. Java Inventory Program Part 3
    By ljk8950 in forum New To Java
    Replies: 18
    Last Post: 07-28-2008, 05:47 AM
  4. Inventory Program Part 3 - DUE TODAY (7/28/08)
    By ljk8950 in forum New To Java
    Replies: 7
    Last Post: 07-27-2008, 10:28 PM
  5. Inventory part 3 program problems
    By badness in forum New To Java
    Replies: 1
    Last Post: 12-17-2007, 07:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •