Help calling class inventory

I am writing a program for inventory. I have my inventoryMain.java file, then wrote another file called inventory.java. I cant figure out how to get my main to call the other inventory file. Every inventory class in my main has an error. My inventory.java file compiles with no problem it is listed at bottom of inventorymain.java

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.BufferedReader;

publicclass inventoryMain

{

// main method begins execution of java application

publicstaticvoid main(String[] args)

{

//create inventory of pens

inventory pens =new inventory();//creating the inventory with empty constructor

pens.setItemNum( 1 );

pens.setName("pens" );

pens.setPrice( 1.5 );

pens.setUnits( 346 );

//create inventory of pencils

inventory pencils =new inventory();//creating the inventory with empty constructor

pencils.setItemNum( 2 );

pencils.setName("pencils" );

pencils.setPrice( .59 );

pencils.setUnits( 487 );

//create inventory of markers

inventory markers =new inventory();//creating the inventory with empty constructor

markers.setItemNum( 3 );

markers.setName("markers" );

markers.setPrice( 1.39 );

markers.SetUnits( 168 );

//create inventory of paperclips

inventory paperclips =new inventory();//creating the inventory with empty constructor

paperclips.setItemNum( 4 );

paperclips.setName("paperclips" );

paperclips.setPrice( 1.0 );

paperclips.setUnits( 136 );

//create inventory of glue

inventory glue =new inventory();//creating the inventory with empty constructor

glue.setItemNum( 5 );

glue.setName("glue" );

glue.setPrice( .79 );

glue.setUnits( 72 );

//create inventory of tape

inventory tape =new inventory();//creating the inventory with empty constructor

tape.setItemNum( 6 );

tape.setName("tape" );

tape.setPrice( .49 );

tape.setUnits( 127 );

//create inventory of paper

inventory paper =new inventory();//creating the inventory with empty constructor

paper.setItemNum( 7 );

paper.setName("paper" );

paper.setPrice( 1.79 );

paper.setUnits( 203 );

//Display the inventories

pens.showInventory();

pencils.showInventory();

markers.showInventory();

paperclips.showInventory();

glue.showInventory();

tape.showInventory();

paper.showInventory();

}//end main

}//end class inventoryMain

_

publicclass inventory

{

privateint itemNum;

private String name =new String();

privateint units;

privatedouble price;

//All getters and setters

publicint getItemNum()

{

return itemNum;

}

publicvoid setItemNum(int itemNum)

{

this.itemNum = itemNum;

}

public String getName()

{

return name;

}

publicvoid setName(String name)

{

this.name = name;

}

publicint getUnits()

{

return units;

}

publicvoid setUnits(int units)

{

this.units = units;

}

publicdouble getPrice()

{

return price;

}

publicvoid setPrice(double price)

{

this.price = price;

}

//Constructors

inventory()// Empty Constructor

{

}

//Constructor that takes arguments

inventory(int _itemNum, String _name,int _units,double _price)//Constructor

{

itemNum = _itemNum;

name = _name;

units = _units;

price = _price;

}

//Computes value of inventory

publicdouble valueOfInventory()

{

return price * units;

}

//displays the details of the inventory

publicvoid showInventory()

{

System.out.println("Product Name: "+name);

System.out.println("Item Number: "+itemNum);

System.out.println("Number of Units: "+units);

System.out.println("Unit Price: "+price);

//call the valueOfInventory() method and display the value

System.out.println("The value of the inventory of "+name+" is = "+valueOfInventory());

}

}

[8073 byte] By [javahelp44a] at [2007-11-27 7:28:20]
# 1

So? What's the problem exactly? What error messages are you getting?

By the way, you should follow Java naming conventions. Class names start with a capital letter.

Also...IMHO, no-arg constructors for data objects is a bad idea. It's meaningless. When you buy a car, you buy a specific car, you don't pay for generic car-ness and then fill in the details later.But using a no-arg constructor you're creating objects in an incomplete state, and that can lead to bugs.

paulcwa at 2007-7-12 19:08:28 > top of Java-index,Java Essentials,Java Programming...
# 2
in inventoryMain.javafor every line that calls inventory ( inventory pens, inventory pencils, for eample) is underlined and the error says:can not find symbolsymbol : class inventorylocation : class inventoryMain
javahelp44a at 2007-7-12 19:08:28 > top of Java-index,Java Essentials,Java Programming...
# 3
Ok Paul. I think just by changing the class to a capital letter fixed this for me, I done this on my last program also. Thank you for your help! Here's my points.
javahelp44a at 2007-7-12 19:08:28 > top of Java-index,Java Essentials,Java Programming...
# 4
Hmmm...If changing the case of the class name fixed the problem, then I'm guessing that the problem was that the filenames started with upper-case letters, and that confused the compiler. Standardizing the names fixed it.
paulcwa at 2007-7-12 19:08:28 > top of Java-index,Java Essentials,Java Programming...
# 5
Paul; I spoke to soon, I am right back where I started. I have the same errors.
javahelp44a at 2007-7-12 19:08:28 > top of Java-index,Java Essentials,Java Programming...
# 6
I now get a package Inventory does not exist error
javahelp44a at 2007-7-12 19:08:28 > top of Java-index,Java Essentials,Java Programming...
# 7

Is the class now called "Inventory"? Is it in a file called "Inventory.java"?

Did you add a line like this to your Inventory.java file?

package Inventory;

If so, you shouldn't have, because under Java naming conventions, packages start with a lower-case letter. Also, you're using the word "inventory" a lot here. You're supposed to use meaningful names that help differentiate the different parts of a system. Having a class called "inventory" in a package called "inventory" and called from a class called "inventoryMain" doesn't really help differentiate things much.

Using packages is generally a good idea, but at this point I'd suggest that you forget them for now, and just get a base case working. Then go back and add a package structure later.

paulcwa at 2007-7-12 19:08:28 > top of Java-index,Java Essentials,Java Programming...
# 8

Paul, I think I am ok now... I am learning how to use netbeans, I think I had all kinds of things goofed up ( different names on files and in different locations). So I restarted a project and added an empty .java file then started over again, It works this time. I will go back and do the suggestions that you have offered to me. Thank you again Paul for your expertise!!

javahelp44a at 2007-7-12 19:08:28 > top of Java-index,Java Essentials,Java Programming...
# 9

> Also...IMHO, no-arg constructors for data objects is

> a bad idea. It's meaningless. When you buy a car,

> you buy a specific car, you don't pay for generic

> car-ness and then fill in the details later.But

> using a no-arg constructor you're creating objects in

> an incomplete state, and that can lead to bugs.

A lot of tools (especially AOP oriented tools but also others) however require one because they create instances using reflection and immediately afterwards call setters to populate the instance.

jwentinga at 2007-7-12 19:08:28 > top of Java-index,Java Essentials,Java Programming...