import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.util.*;
public class Inventorytest4 extends JFrame
{
//Define private variables of type JLabel to hold the data for display
private JLabel label1, label2, label3, label4, label5;
// set up GUI
public Inventorytest4 ()
{
super( "Inventory of DVD Movies" );
// get content pane and set its layout
Container container = getContentPane();
container.setLayout( new FlowLayout() );
//create an array of products
Movie[] Movies = new Movie[4];
//populate the array
Movies[0] = new Movie("111", "Superman", 11, 12.99, "PG");
Movies[1] = new Movie("222", "Batman Returns", 9, 11.99, "PG 13");
Movies[2] = new Movie("333", "Madagascar", 10, 10.99, "G");
Movies[3] = new Movie("444", "Cars", 15, 13.99, "G");
//initiate decimal format object
NumberFormat n = NumberFormat.getCurrencyInstance(Locale.US);
DecimalFormat Currency = new DecimalFormat("#0.00");
//print the inventory information
label1 = new JLabel("<html><font size=+1>Non sorted Movies inventory</html>");
container.add( label1 );
for(int i = 0; i < Movies.length; i++)
{
Movie aDVD = Movies;
label2 = new JLabel("DVD Name: " + aDVD.getName() +
"| Rating: " + aDVD.getRating() +
"| Item #: " + aDVD.getNum() +
"| Number in stock: " + aDVD.getStock() +
"| Price: $" + Currency.format(aDVD.getPrice()) +
"| Restocking fee(5%): " + n.format(aDVD.getRestockingFee()) +
"| Inventory Value: " + n.format(aDVD.getInventoryTotal()) + "\n");
container.add(label2);
}
//sorting the array
Movies[0].SortInventory(Movies);
//print the inventory information
label3 = new JLabel("<html><font size=+1>Sorted Movies inventory</html>");
container.add( label3 );
for(int i = 0; i < Movies.length; i++)
{
Movie aDVD = Movies;
label4 = new JLabel("DVD Name: " + aDVD.getName() +
"| Rating: " + aDVD.getRating() +
"| Item #: " + aDVD.getNum() +
"| Number in stock: " + aDVD.getStock() +
"| Price: $" + Currency.format(aDVD.getPrice()) +
"| Restocking fee(5%): " + n.format(aDVD.getRestockingFee()) +
"| Inventory Value: " + n.format(aDVD.getInventoryTotal()) + "\n");
container.add(label4);
}
//calulcating total value and displaying
Double totalInv = Movies[0].CalculateTotalInventoryValue(Movies);
label5 = new JLabel("Total Inventory Value: " + n.format(totalInv) + "\n");
container.add( label5 );
}
public static void main(String args[])
{
Inventorytest4 frame = new Inventorytest4();
//Set JLabel window size and visibility
frame.setSize( 900, 300 );
frame.setVisible( true );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
}
C:\Documents and Settings\paccda\Desktop\Inventorytest4.java:43: incompatible types
found : Movie[]
required: Movie
Movie aDVD = Movies;
^
C:\Documents and Settings\paccda\Desktop\Inventorytest4.java:65: incompatible types
found : Movie[]
required: Movie
Movie aDVD = Movies;
^
2 errors
Tool completed with exit code 1

New Topic/Question
Reply



MultiQuote





|