Hi,
I'm new and am trying....attempting is more like it... to compile a code for a DVD Inventory program. This inventory program is showing 32 errors after I try to compile it and I have not got a clue where to begin to understand what the errors mean and what I need to do to fix it. The worst part is that I have to add a Save button that saves to a specific directory and then add a search button to the GUI. Any help would be appreciated as I am an extreme novice and I need to complete this by Saturday Night..
Here is the code first
// $DVDInventoryValue.java
// Inventory using an array to store DVD name, DVD number, amount in
// stock, and price per DVD.
public class $DVDInventoryValue
{
private string product name; // name of product this inventory represents
private int stock []; // array of each product stock
// two-argument constuctor initializes inventoryName and stock array
public $InventoryValue ( String name, int stockArray[] )
{
inventoryName = name; // initialize inventoryName
stock = stockArray; // store stock
} // end two-argument $InventoryValue constructor
// method to set the inventory name
public void setInventoryName( string name)
{
inventoryName = name; // store the inventory name
} // end method setInventoryName
// method to retrieve the inventory name
public string getInventoryName()
{
return inventoryName;
} // end method get InventoryName
// display a message to the $DVDInventoryValue user
public void displayMessage()
{
// get InventoryName gets the name of the inventory
System.out.printf( "This is the inventory for\n%s!\n\n",
getInventoryName() );
} // end method displayMessage
public class DVDActor
{
private String actorName;
private String dvdTitle;
private integer dvdNumber;
private double stockAmount; // amount in stock
private double dvdPrice; // price of DVD
private double restockingFeeRate; // restocking percentage
private double $inventoryValue; // value of inventory
// seven-argument constructor
public DVDActor (String name, String title,
String dvd number, double stock, double price, double rate, double value )
{
// implicit call to Object constructor occurs here
actorName = name;
dvdTitle = title;
dvdNumber = number;
setdvdPrice ( price ); // validate and store price
setrestockingfeerate( rate ); // validate and store restocking fee rate
set $inventoryValue( value ); // validate and store inventory value
} // end seven-argument DVDActor constructor
// set actor name
public void setActorName( String name )
{
actorName = name;
} // end method setActorName
// return actor name
public String getActorName()
// set dvd title
public void setDVDTitle( String title )
{
dvdTitle = title;
} // end method setDVDTitle
// return dvd title
public String getDVDTitle()
{
return dvdTitle;
} // end method get DVDTitle
// set dvd number
public void set DVDNumber( String number )
{
dvdNumber = number; // should validate
} // end method set DVDNumber
// return dvd number
public String getDVDNumber()
{
return dvdNumber
} // end method get DVDNumber
// set amount in stock
public void setStockAmount ( double stock )
{
stockAmount = ( stock < 0.0 ) ? 0.0 : stock;
} // end method setStockAmount
// return amount in stock
public double getStockAmount()
{
return stockAmount;
} // end method getStockAmount
// set dvd price
public void setDVDPrice( double rate )
{
dvdPrice = ( price < 0.0 ) ? 0.0 : price;
} // end method setDVDPrice
// return dvd price
public double getDVDPrice()
{
return dvdPrice;
} // end method getDVDPrice
// set restocking fee rate
public void setRestockingFeeRate( double rate )
{
restockingFeeRate = ( rate o.5 ) rate : 0.5;
} // end method setRestockingFeeRate
// return restocking fee rate
public double getRestockingFeeRate()
{
return restockingFeeRate;
} // end method getRestockingFeeRate
// set inventory value
public void set$InventoryValue( double value )
{
$inventoryValue = ( value < 0.0 ) ? 0.0 : value;
} // end method set$InventoryValue
// return inventory value
public double get$InventoryValue()
{
return $inventoryValue;
} // end method get$InventoryValue
// calculate feeinventory
public double feeinventory()
{
return $inventoryValue + ( restockingFeeRate * stock );
} // end method feeinventory
// return String representation of ActorName
public String toString()
{
return String.format(
"%s: %s %s\n%s: %s\n%s: %.2f\n%s: %.2f\n%s: %.2f",
"dvd actor", dvdTitle, "dvd number", dvdNumber,
"amount in stock", stockAmount, "dvd price", dvdPrice,
"restocking fee rate", restockingFeeRate,
"value of inventory", $inventoryValue );
} // end method toString
// perform various operations on the data
public void processStock()
// output Stock array
outputStock();
// call method getValue to calculate the value of product
System.out.printf( "Product value is %.2f\n",getValue() );
// call method getInventory to calculate entire value of inventory
System.out.printf( "Inventory value is %d\n", getinventory() );
// call outputBarChart to print product distribution chart
outputBarChart();
} // end method processStock
{
int total = 0; // initialize total
// sum stock for one product
for ( int stock : stock )
total += stock;
}
// output bar chart displaying product distribution
public void outputBarChart()
{
System.out.println ( "Stock distribution:" );
// stores frequency of DVD numbers in each range of 100 numbers
int frequency[] = new int[ 101 ];
// for each number, increment the appropriate frequency
for ( int number : number )
++frequency[ number / 100 ];
// for each number frequency, print bar in chart
for ( int count = 0; count < frequency.length; count++ )
{
// output bar label ( "000-099: ", ..., "100-999", "1000: " )
if ( count == 10 )
System.out.printf( "%5d: ", 1000 );
else
System.out.printf( "%02d-%02d: ",
count * 100, count * 100 + 99 );
// stores frequency of amount in stock in each range of 100 numbers
int frequency[] = new int [ 101 ];
// for each amount, increment the appropriate frequency
for ( int amount : amount )
++ frequency[ number / 100 ];
// for each amount frequency, print bar in chart
for ( int count = 0; count < frequency.length, count++ )
{
// output bar label ( "000-099: ", ..., "100-999", "1000: " )
if ( count == 10 )
System.out.printf( "%5d: ", 1000 );
else
System.out.printf( "%02d-%02d: ",
count * 100, count * 100 + 99 );
// stores frequency of DVD price in each range of 100 numbers
int frequency[] = new int [ 101 ];
// for each price, increment the appropriate frequency
for ( int price : price )
++ frequency[ number / 100 ];
// for each price frequency, print bar in chart
for ( int count = 0; count < frequency.length, count++ )
{
// output bar label ( "000-099: ", ..., "100-999", "1000: " )
if ( count == 10 )
System.out.printf( "%5d: ", 1000 );
else
System.out.printf( "%02d-%02d: ",
count * 100, count * 100 + 99 );
// print bar of asterisks
for ( int stars = 0; stars < frequency[ count ]; stars++ )
System.out.print( "*" );
System.out.println(); // start a new line of output
} // end outer for
} // end method outputBarChart
// output the contents of the stock array
public void outputStock()
{
System.out.println( "The stock is :\n" );
// output each product name's stock
for ( int product = 0; product < stock.length; product++ )
System.out.printf( "Product %2d: %3d\n",
product + 1, stock[ product ] );
} // end method outputStock
// Display program that uses JOption Pane for input and output.
import javax.swing.JOptionPane; // program uses JOptionPane
public class Display
{
public static void main( String args[] )
{
// obtain user input from JOptionPane input dialogs
String dvdNumber =
JOptionPane.showInputDialog( "Enter dvd number" );
if ( DVD number < 0 ) {
System.out.println(" DVD number invalid, enter positive number" );
}
else {
String dvdTitle =
JOptionPane.showInputDialog( "Enter dvd title" );
String stockAmount =
JOptionPane.showInputDialog( "Enter stock amount" );
if ( amount in stock < 0 ) {
System.out.println(" amount in stock invalid, enter positive number" );
}
else {
String dvdPrice =
JOptionPane.showInputDialog( "Enter dvd price" );
if ( DVD PRICE < 0 ) {
System.out.println(" DVD price invalid, enter positive number" );
}
else {
// convert String inputs to int values for use in calculation
int number1 = Integer.parseInt( stockAmount );
int number2 = Integer.parseInt( dvdPrice );
$DVDInventoryValue = number1 * number2; // multiply numbers
// create $DVDInventoryValue object
$DVDInventoryValue $DVDInventoryValue1 = new $DVDInventoryValue (
"DVD number", "DVD title", "amount in stock", "DVD price" );
// display initial value of DVD number for $DVDInventoryValue
System.out.printf( "$DVDInventoryValue1 DVD number is: %d\n",
$DVDInventoryValue1.getDVDNumber() );
System.out.printf( "$DVDInventoryValue1 DVD title is %s\n",
$DVDInventoryValue1.getDVDTitle() );
System.out.printf( "$DVDInventoryValue1 amount in stock is %d\n",
$DVDInventoryValue1.getAmountinStock() );
System.out.print( "$InventoryValue1 DVD price is %d/n",
$InventoryValue1.getDVDPrice() );
$DVDInventoryValue = amount * price; // multiply numbers
while ( DVD number <= 0 )
{
System.out.printf( "$DVDInventoryValue is %d\n", $DVDInventoryValue ); //
display
$DVDInventoryValue
} // end while
//Creating radio buttons using ButtonGroup and JRadioButton.
import java.awt.FlowLayout;
import java.awt.DVDs;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
public class RadioButtonFrame extends JFrame
{
private JTextField textField; // used to display field changes
private field dvdNumber; // field for dvd number
private field dvdTitle; // field for dvd title
private field stockAmount; // field for amount in stock
private field dvdPrice; // field for dvd price
private field $dvdInventoryValue; // field for $dvd inventory value
private field previous; // field for previous selection
private field next; // field for next selection
private JRadioButton dvdNumberJRadioButton; // selects dvd number field
private JRadioButton dvdTitleJRadioButton; // selects dvd title field
private JRadioButton stockAmountJRadioButton; // selects amount in stock field
private JRadioButton dvdPriceJRadioButton; // selects dvd price field
private JRadioButton $dvdInventoryValueJRadioButton; // selects $dvd inventory value
field
private JRadioButton previousJRadioButton; // selects previous selection field
private JRadioButton nextJRadioButton; // selects next selection field
// RadioButtonFrame constructor adds JRadioButtons to JFrame
public RadioButtonFrame()
{
super( "RadioButton Test")
setLayout( new FlowLayout() ); // set frame layout
textfield = new JTextField( "Watch the field change", 25 );
add( textField ); // add textField to JFrame
// create radio buttons
dvdNumberJRadioButton = new JRadioButton( "dvdNumber", true );
dvdTitleJRadioButton = new JRadioButton( "dvdTitle", false );
stockAmountJRadioButton = new JRadioButton( "stockAmount", false );
dvdPriceJRadioButton = new JRadioButton( "dvdPrice", false );
$dvdInventoryValueJRadioButton = new JRadioButton( "$dvdInventoryValue", false );
previousJRadioButton = new JRadioButton( "previous", false );
nextJRadioButton = new JRadioButton( "next", false );
add( dvdNumberJRadioButton ); // add dvd number button to JFrame
add( dvdTitleJRadioButton ); // add dvd title button to JFrame
add( stockAmountJRadioButton ); // add stock amount button to JFrame
add( dvdPriceJRadioButton ); // add dvd price button to JFrame
add( $dvdInventoryValueJRadioButton ); // add $dvd inventory value button to JFrame
add( previousJRadioButton ); // add previous button to JFrame
add( nextJRadioButton ); // add next button to JFrame
// create logical relationship between JRadioButtons
radioGroup = new ButtonGroup(); // create ButtonGroup
radioGroup.add( dvdNumberJRadioButton ); // add dvd number to group
radioGroup.add( dvdTitleJRadioButton ); // add dvd title to group
radioGroup.add( stockAmountJRadioButton ); // add stock amount to group
radioGroup.add( dvdPriceJRadioButton ); // add dvd price to group
radioGroup.add( $dvdInventoryValueJRadioButton ); // add $dvd inventory value to
group
radioGroup.add( previousJRadioButton ); // add previous to group
radioGroup.add( nextJRadioButton ); // add next to group
// create field objects
dvdNumber = new number( "%d\n" );
dvdTitle = new title( "%s\n" );
stockAmount = new amount( "%d\n" );
dvdPrice = new price( "%n\d" );
$dvdInventoryValue = new value( "%n\d" );
previous = new previous( "%n\d );
next = new next( "%n\d" );
textField.setfield( dvdNumber ); // set initial field to dvd number
// register events for JRadioButtons
dvdNumberJRadioButton.addItemListener(
new RadioButtonHandler( dvdNumber ) );
dvdTitleJRadioButton,addItemListener(
new RadioButtonHandler( dvdTitle ) );
stockAmountJRadioButton.addItemListener(
new RadioButtonHandler( stockAmount ) );
dvdPriceJRadioButton.addItemListener(
new RadioButtonHandler( dvdPrice ) );
$dvdInventoryValueJRadioButton.addItemListener(
new RadioButtonHandler( $dvdInventoryValue ) );
previousJRadioButton.addItemListener(
new RadioButtonHandler( previous ) );
nextJRadioButton.addItemListener(
new RadioButtonHandler( next ) n);
} // end RadioButtonFrame constructor
// private inner class to handle radio button events
private class RadioButtonHandler implements ItemListener
{
private Field field; // field associated with this listener
public RadioButtonHandler( Field f )
{
field = f; // set the field of this listener
} // end constructor RadioButtonHandler
// handle radio button events
public void itemStateChanged( ItemEvent event )
{
textField.setField( field ); // set field of textField
} // end method itemStateChanged
} // end private inner class RadioButtonHandler
} // end class RadioButtonFrame
// Testing RadioButtonFrame.
// import javax.swing.JFrame
public class RadioButtonTest
{
public static void main( string arg{} )
{
RadioButtonFrame radioButtonFrame = new RadioButtonFrame()
radioButtonFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
radioButtonFrame.setSize( 300, 100 ); // set frame size
radioButtonFrame.setVisible( true ); // display frame
} // end main
} // end class RadioButtonTest
// Using class MouseMotionAdapter
import java.awt.Point;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter
import javax.swing.JPanel;
public class PaintPanel extends JPanel
{
private int pointCount = 0; // count number of points
// array of 1000 java.awt.Point references
private Point points[] = new Point[ 10000 ];
// set up GUI and register mouse event handler
public PaintPanel()
{
// handle frame mouse motion event
addMouseMotionListener(
new MouseMotionAdapter() // anonymous inner class
{
// store drag coordinates and repaint
public void mouseDragged( MouseEvent event )
{
if ( pointCount < points.length )
{
points[ pointCount ] = event.getPoint(); // find point
pointCount++; // increment number of points in array
repaint(); // repaint JFrame
} // end if
} // end method mouseDragged
} // end anonymous inner class
); // end call to addMouseMotionListener
} // end PaintPanel constructor
// draw company logo in a 4-by4- bounding box at specified location on window
public void paintComponent( Graphics g )
{
super.paintComponent( g ); // clears drawing area
// draw all points in array
for ( int i = 0; i < pointCount; i++ )
g.fillLogo( points[ i ].x, points[ i ].y, 4, 4 );
} // end method paintComponent
} // end class PaintPanel
// display result in a JOPtionPane message dialog
JOptionPane.showMessageDialog( null, "The dvd number is",
JOptionPane,PLAIN_MESSAGE );
JOptionPane.showMessageDialog( null, "The dvd title is",
JOptionPane,PLAIN_MESSAGE );
JOptionPane.showMessageDialog( null, "The amount in stock is",
JOptionPane,PLAIN_MESSAGE );
JOptionPane.showMessageDialog( null, "The dvd price is",
JOptionPane.PLAIN_MESSAGE );
JOptionPane.showMessageDialog( null, "The $dvd inventory value is",
JOptionPane.PLAIN_MESSAGE );
// get dvd actor data
System.out.println(
"DVD actor information obtained by get methods: \n" );
System.out.printf( "%s\n", "Actor name is",
dvdactor.getActorName() );
System.out.printf( "%s %s\n", "Dvd title is",
dvdactor.getDVDTitle() );
System.out.printf( "%s %s\n", "DVD number is",
dvdactor.getDVDNumber() );
System.out.print( "%s %.2f\n", "DVD price is",
dvdactor.getDVDPrice() );
System.out.prinf( "%s %.2f\n", "Restocking fee rate is",
dvdactor.getRestockingFeeRate() );
System.out.printf( "%s %.2f\n", "$Inventory value is",
dvdactor.get$InventoryValue() );
dvdactor.set$InventoryValue( 1000 ); // set inventory value
System.out.printf( "\n%s:\n\n%s\n",
"Updated dvd actor information obtained by toString",
dvdactor.toString()
} // end method main
} // end class DVDActor
} // end class $DVDInventoryValue
I tried to compile it and it gave me like 33 errors. I would copy and paste the errors here but I dont know how to get them off of DOS....if someone can help me I would be indebted forever!!!