Ok, I am working on an inventory program and this is where I am at thus far. I seem to be getting two errors that I can not figure out. I will post the errors at the end of the code. - import java.util.*;
-
import java.awt.*;
-
import javax.swing.*;
-
import java.awt.event.*;
-
-
-
-
public class Inventory extends JFrame// Main class
-
{
-
-
-
private JLabel prodNameLabel;
-
private JLabel numberLabel;
-
private JLabel unitLabel;
-
private JLabel priceLabel;
-
private JLabel featureLabel;
-
private JLabel valueLabel;
-
private JLabel rstkLabel;
-
private JLabel totalLabel;
-
private JTextField prodNameField;
-
private JTextField numberField;
-
private JTextField unitField;
-
private JTextField priceField;
-
private JTextField featureField;
-
private JTextField valueField;
-
private JTextField rstkField;
-
private JTextField totalField;
-
private JButton firstBtn;
-
private JButton prevBtn;
-
private JButton nextBtn;
-
private JButton lastBtn;
-
private JPanel buttonJPanel;
-
private JPanel fieldJPanel;
-
private JPanel fontJPanel;
-
private List<ProductAdd> nwProduct;
-
private int currProd = 0;
-
private double total; // variable for total inventory
-
-
-
-
public Inventory()
-
{
-
initComponents();
-
}
-
-
private void initComponents()
-
{
-
prodNameLabel = new JLabel("Product Name:");
-
numberLabel = new JLabel("Item Number:");
-
unitLabel = new JLabel("In Stock:");
-
priceLabel = new JLabel("Each Item Cost:");
-
featureLabel = new JLabel("Type of Item:");
-
valueLabel = new JLabel("Value of Item Inventory:");
-
rstkLabel = new JLabel("Cost to Re-Stock Item:");
-
totalLabel = new JLabel("Total Value of Inventory:");
-
-
firstBtn = new JButton("First");
-
prevBtn = new JButton("Previous");
-
nextBtn = new JButton("Next");
-
lastBtn = new JButton("Last");
-
-
prodNameField = new JTextField();
-
prodNameField.setEditable(false);
-
numberField = new JTextField();
-
numberField.setEditable(false);
-
unitField = new JTextField();
-
unitField.setEditable(false);
-
priceField = new JTextField();
-
priceField.setEditable(false);
-
featureField = new JTextField();
-
featureField.setEditable(false);
-
valueField = new JTextField();
-
valueField.setEditable(false);
-
rstkField = new JTextField();
-
rstkField.setEditable(false);
-
totalField = new JTextField();
-
totalField.setEditable(false);
-
-
prodNameLabel.setSize(200, 20);
-
numberLabel.setSize(200, 20);
-
unitLabel.setSize(200, 20);
-
priceLabel.setSize(200, 20);
-
featureLabel.setSize(200, 20);
-
valueLabel.setSize(200, 20);
-
rstkLabel.setSize(200, 20);
-
totalLabel.setSize(200, 20);
-
-
prodNameField.setSize(100, 20);
-
numberField.setSize(100, 20);
-
unitField.setSize(100, 20);
-
priceField.setSize(100, 20);
-
featureField.setSize(100, 20);
-
valueField.setSize(100, 20);
-
rstkField.setSize(100, 20);
-
totalField.setSize(100, 20);
-
-
buttonJPanel = new JPanel(); // set up panel
-
buttonJPanel.setLayout( new GridLayout(1, 4)); //set layout
-
// add buttons to buttonJPanel
-
buttonJPanel.add(firstBtn);
-
buttonJPanel.add(prevBtn);
-
buttonJPanel.add(nextBtn);
-
buttonJPanel.add(lastBtn);
-
-
-
-
}
-
public static void main( String args[])
-
{
-
product[] myProduct = new product[5];
-
//Company[] myCompany = new Company[5];
-
-
product p1 = new Company("Mad Dash", 20003, 5, 30, "EIDOS");
-
product p2 = new Company("Fuzion Frenzy", 74512, 2, 10, "MicroSoft");
-
product p3 = new Company("Time Splitters 2", 20009, 3, 45, "EIDOS");
-
product p4 = new Company("Night Caster", 74522, 8, 5, "MicroSoft");
-
product p5 = new Company("Lego Star Wars II", 32976, 1, 50, "LucasArts");
-
-
myProduct[0] = p1;
-
myProduct[1] = p2;
-
myProduct[2] = p3;
-
myProduct[3] = p4;
-
myProduct[4] = p5;
-
-
double totalValue = 0.0;
-
-
for (int c=0; c < 5; c++)
-
{
-
totalValue = totalValue + myProduct[c].itemCalculate();
-
}
-
-
Arrays.sort(myProduct); // function used to sort arrays
-
-
for(product p: myProduct)
-
{
-
System.out.println(p);
-
System.out.println();
-
}
-
System.out.println("Total Inventory value is: $"+totalValue);
-
-
} //end main
-
-
} //end Inventory
-
Here are the two errors that I recieve - C:\Users\Brian\Desktop\Java Inventory program\Inventory.java:35: cannot find symbol
-
symbol : class list
-
location: class Inventory
-
private list<ProductAdd> nwProduct;
-
^
-
C:\Users\Brian\Desktop\Java Inventory program\Inventory.java:35: cannot find symbol
-
symbol : class ProductAdd
-
location: class Inventory
-
private list<ProductAdd> nwProduct;
-
^
-
2 errors
-
-
Tool completed with exit code 1
-
-
Can not figure out why this will not compile... What am I missing.
8 2039
C:\Users\Brian\Desktop\Java Inventory program\Inventory.java:35: cannot find symbol
symbol : class list
location: class Inventory
private list<ProductAdd> nwProduct;
^
C:\Users\Brian\Desktop\Java Inventory program\Inventory.java:35: cannot find symbol
symbol : class ProductAdd
location: class Inventory
private list<ProductAdd> nwProduct;
^
2 errors
Tool completed with exit code 1
Can not figure out why this will not compile... What am I missing.
Hi,
luk at ur first error...compiler is not able to find symbol *list*...I think it should be *List*.
Same problem can be in second error also...check for ProductAdd..Is it the right name. check for spelling also..
thanks and regards,
madhoriya22
I tried both ways with the capitols. Still got the same errors.
I tried both ways with the capitols. Still got the same errors.
Hi,
Where are you using this List<ProductAdd> nwProduct in ur program?
thanks and regards,
madhoriya22.
Hi
private List<ProductAdd> nwProduct declaration is wrong
use following
private List nwProduct;
ok, changed that line of code to read what you sugested and here are the error codes. - C:\Users\Brian\Desktop\Java Inventory program\Inventory.java:35: reference to List is ambiguous, both class java.awt.List in java.awt and class java.util.List in java.util match
-
private List nwProduct;
-
^
-
1 error
-
-
Tool completed with exit code 1
-
What is ment by where is my refrence?
ok, changed that line of code to read what you sugested and here are the error codes. - C:\Users\Brian\Desktop\Java Inventory program\Inventory.java:35: reference to List is ambiguous, both class java.awt.List in java.awt and class java.util.List in java.util match
-
private List nwProduct;
-
^
-
1 error
-
-
Tool completed with exit code 1
-
What is ment by where is my refrence?
Hi,
where u have initialized ur List? Compiler is not able to differentiate that Is it a AWT List or util List.
Thanks and regards,
madhoriya22.
Ok, so I removed the line to work backwards to move forward. Now, it complies but the GUI does not show up. When I run the program it goes to the comand prompt. -
import java.util.*;
-
import java.awt.*;
-
import javax.swing.*;
-
import java.awt.event.*;
-
import javax.swing.JFrame; // provides basic window features
-
import javax.swing.JLabel; // displays text and images
-
import javax.swing.SwingConstants; // common constants used with Swing
-
import javax.swing.Icon; // interface used to manipulate images
-
import javax.swing.ImageIcon; // loads images
-
-
-
-
public class Inventory extends JFrame// Main class
-
{
-
-
-
private JLabel prodNameLabel;
-
private JLabel numberLabel;
-
private JLabel unitLabel;
-
private JLabel priceLabel;
-
private JLabel featureLabel;
-
private JLabel valueLabel;
-
private JLabel rstkLabel;
-
private JLabel totalLabel;
-
private JTextField prodNameField;
-
private JTextField numberField;
-
private JTextField unitField;
-
private JTextField priceField;
-
private JTextField featureField;
-
private JTextField valueField;
-
private JTextField rstkField;
-
private JTextField totalField;
-
private JButton firstBtn;
-
private JButton prevBtn;
-
private JButton nextBtn;
-
private JButton lastBtn;
-
private JPanel buttonJPanel;
-
private JPanel fieldJPanel;
-
private JPanel fontJPanel;
-
private int currProd = 0;
-
private double total; // variable for total inventory
-
-
-
-
public Inventory()
-
{
-
initComponents();
-
}
-
-
private void initComponents()
-
{
-
prodNameLabel = new JLabel("Product Name:");
-
numberLabel = new JLabel("Item Number:");
-
unitLabel = new JLabel("In Stock:");
-
priceLabel = new JLabel("Each Item Cost:");
-
featureLabel = new JLabel("Type of Item:");
-
valueLabel = new JLabel("Value of Item Inventory:");
-
rstkLabel = new JLabel("Cost to Re-Stock Item:");
-
totalLabel = new JLabel("Total Value of Inventory:");
-
-
firstBtn = new JButton("First");
-
prevBtn = new JButton("Previous");
-
nextBtn = new JButton("Next");
-
lastBtn = new JButton("Last");
-
-
prodNameField = new JTextField();
-
prodNameField.setEditable(false);
-
numberField = new JTextField();
-
numberField.setEditable(false);
-
unitField = new JTextField();
-
unitField.setEditable(false);
-
priceField = new JTextField();
-
priceField.setEditable(false);
-
featureField = new JTextField();
-
featureField.setEditable(false);
-
valueField = new JTextField();
-
valueField.setEditable(false);
-
rstkField = new JTextField();
-
rstkField.setEditable(false);
-
totalField = new JTextField();
-
totalField.setEditable(false);
-
-
prodNameLabel.setSize(200, 20);
-
numberLabel.setSize(200, 20);
-
unitLabel.setSize(200, 20);
-
priceLabel.setSize(200, 20);
-
featureLabel.setSize(200, 20);
-
valueLabel.setSize(200, 20);
-
rstkLabel.setSize(200, 20);
-
totalLabel.setSize(200, 20);
-
-
prodNameField.setSize(100, 20);
-
numberField.setSize(100, 20);
-
unitField.setSize(100, 20);
-
priceField.setSize(100, 20);
-
featureField.setSize(100, 20);
-
valueField.setSize(100, 20);
-
rstkField.setSize(100, 20);
-
totalField.setSize(100, 20);
-
-
buttonJPanel = new JPanel(); // set up panel
-
buttonJPanel.setLayout( new GridLayout(1, 4)); //set layout
-
// add buttons to buttonJPanel
-
buttonJPanel.add(firstBtn);
-
buttonJPanel.add(prevBtn);
-
buttonJPanel.add(nextBtn);
-
buttonJPanel.add(lastBtn);
-
-
-
-
}
-
public static void main( String args[])
-
{
-
product[] myProduct = new product[5];
-
//Company[] myCompany = new Company[5];
-
-
product p1 = new Company("Mad Dash", 20003, 5, 30, "EIDOS");
-
product p2 = new Company("Fuzion Frenzy", 74512, 2, 10, "MicroSoft");
-
product p3 = new Company("Time Splitters 2", 20009, 3, 45, "EIDOS");
-
product p4 = new Company("Night Caster", 74522, 8, 5, "MicroSoft");
-
product p5 = new Company("Lego Star Wars II", 32976, 1, 50, "LucasArts");
-
-
myProduct[0] = p1;
-
myProduct[1] = p2;
-
myProduct[2] = p3;
-
myProduct[3] = p4;
-
myProduct[4] = p5;
-
-
double totalValue = 0.0;
-
-
for (int c=0; c < 5; c++)
-
{
-
totalValue = totalValue + myProduct[c].itemCalculate();
-
}
-
-
Arrays.sort(myProduct); // function used to sort arrays
-
-
for(product p: myProduct)
-
{
-
System.out.println(p);
-
System.out.println();
-
}
-
System.out.println("Total Inventory value is: $"+totalValue);
-
-
} //end main
-
-
} //end Inventory
-
-
-
import java.util.*;
-
-
public class Company extends product implements Comparable
-
{
-
private String developer;
-
//double total;
-
-
/** Creates a new instance of Company */
-
public Company()
-
{
-
super();
-
String developer ="";
-
//total =0.0;
-
}
-
public Company(String productName, int itemNumber, double unitProduct, double priceProduct, String developer)
-
{
-
super(productName, itemNumber, unitProduct, priceProduct);
-
this.developer = developer;
-
}
-
-
public void setDeveloper( String developer)
-
{
-
this.developer = developer;
-
}
-
public String getDeveloper()
-
{
-
return developer;
-
}
-
-
public double itemCalculate()
-
{
-
return (super.itemCalculate()*.05)+super.itemCalculate();
-
}
-
-
public int compareTo (Object o) // use the compareTo method
-
{
-
product p = (product)o;
-
return productName.compareTo(p.getProductName());
-
}
-
-
public String toString()
-
{
-
return super.toString()+ "\nCompany: "+ developer +"\nPrice with restock fee: $"+itemCalculate();
-
}
-
}
-
-
-
-
-
-
import java.util.*; // program uses any class available
-
-
class product implements Comparable
-
{
-
public String productName; // class variable that stores the item name
-
private int itemNumber; // class variable that stores the item number
-
private double unitProduct; // class variable that stores the quantity in stock
-
private double priceProduct; // class variable that stores the item price
-
-
/** Creates a new instance of product */
-
public product() // Constructor for Product class
-
{
-
productName = "";
-
itemNumber = 0;
-
unitProduct = 0.0;
-
priceProduct = 0.0;
-
}
-
public product( String productName, int itemNumber, double unitProduct, double priceProduct) // Constructor for myProduct class
-
{
-
this.productName = productName;
-
this.itemNumber = itemNumber;
-
this.unitProduct = unitProduct;
-
this.priceProduct = priceProduct;
-
}
-
-
public void setProductName(String name) // Method to set the item name
-
{
-
this.productName = productName;
-
}
-
public String getProductName() // Method to get the item name
-
{
-
return productName;
-
}
-
public void setItemNumber(int number) // Method to set the item number
-
{
-
this.itemNumber = itemNumber;
-
}
-
public int getItemNumber() // Method to get the item name
-
{
-
return itemNumber;
-
}
-
public void setUnitProduct(double unit) // Method to set the item number
-
{
-
this.unitProduct = unitProduct;
-
}
-
public double getUnitProduct() // Method to get the item name
-
{
-
return unitProduct;
-
}
-
public void setPriceProduct(double price) // Method to set the item number
-
{
-
this.priceProduct = priceProduct;
-
}
-
public double getPriceProduct() // Method to get the item name
-
{
-
return priceProduct;
-
}
-
-
// Calculation method
-
public double itemCalculate()
-
{
-
return unitProduct * priceProduct; // multiply for total for each item
-
-
} // end calculation
-
public int compareTo (Object o) // use the compareTo method
-
{
-
product p = (product)o;
-
return productName.compareTo(p.getProductName());
-
}
-
-
public String toString() // displays products
-
{
-
return "Title: "+productName+
-
"\nBarcode: "+itemNumber+
-
"\nNumber of Xbox games: "+(int)unitProduct+
-
"\nPrice: $"+priceProduct+
-
"\nTotal: $"+itemCalculate();
-
} // end toString
-
-
-
}//end class Supplies
-
-
Ok, so I removed the line to work backwards to move forward. Now, it complies but the GUI does not show up. When I run the program it goes to the comand prompt.
Hi,
Declare ur list like this .. to remove the ambiguity -
-
private java.awt.List nwProduct;
-
private void initComponents()
-
{
-
nwProduct = new java.awt.List();
-
GUI is not creating bcoz u r not creating any object of ur inventory class in main method.
thanks and regards,
madhoriya22
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jamie Fryatt |
last post by:
Hi everyone, here's what id like to do.
I have a table with 2 fields, name and value
I need to be able to add multiple records quickly, for example I need to add
name value
abc 1...
|
by: sp0 |
last post by:
Is there a reason why to make mix numbers improper when adding?
It seems when subtracting and adding, adding a subtracting the whole
numbers and fraction parts should be sufficient? what'ch think
|
by: hzgt9b |
last post by:
When adding my VB .NET solution (with two sub-projects) the folder structure
in VSS gets an extra level of folders...
For example, here's the structure of the solution on my C:\...
|
by: Jim Heavey |
last post by:
Trying to figure out the technique which should be used
to add rows to a datagrid. I am thinking that I would
want an "Add" button on the footer, but I am not quite
sure how to do that. Is that...
|
by: Robin Thomas |
last post by:
I am fairly new to ASP.NET so I think I am missing something fundamental.
Anyway, quite often I am pulling data from a database, but then I need to
use that data to produce more data. A simple...
|
by: Sileesh |
last post by:
Hi
I have html table and a Button in an Aspx page. I am adding one row with
some textboxes to Html table each time i click on the Button thru Javascript.
Now problem is when when i try to...
|
by: seanmayhew |
last post by:
I have a form page that that while editing saves the data to an xml doc
before submitting to db. On each page
unload it saves the xmldoc as the user can add multiple items to the
company like...
|
by: vb |
last post by:
Hi,
I am new to .Net.
I am using a Combo Box in my windows forms. I am adding the items by
creating the instances and adding the same to the list.
My questions/doubts are:
1. If I have 25 to...
|
by: Kadett |
last post by:
Hi all, I have following problem: I'm creating a ListView (Details) control
at run-time and filling it with some records (let's say 10 000). This
operation seems to be quite fast, but when I call...
|
by: AndyL69 |
last post by:
Hello
I've got a very strange Problem. When im adding a new ACE entry to a UNC Direcotry the inherented ACL's will be lost. When I'm adding a new ACE to a directory / file in this UNC path the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |