0

Hello Everyone!

I'm Glen, a student beginning to learn about Java.

I need help, my instructor is not useful and my fellow students have no idea what their doing; their lost as well! I have an assignement which was do two days ago; i was not able to produce a final product because I can not understand exactly what it is that i'm doing.
Please....I need someone's Java expertise and advice!

NOTE: I'm not looking for someone to do my homework for me; I just need a helping hand into making me see where things go and what I have done wrong by explaining things to me as the process goes into play!!!

Below is the assignement and my code which I have not posted because of insufficient knowledge of what I'm doing!

CheckPoint: Inventory Program Part 3
· Resource: Java: How to Program
· Due Date: Day 7 [Individual] forum
· Modify the Inventory Program by creating a subclass of the product class that uses one
additional unique feature of the product you chose (for the DVDs subclass, you could use
movie title, for example). In the subclass, create a method to calculate the value of the
inventory of a product with the same name as the method previously created for the
product class. The subclass method should also add a 5% restocking fee to the value of
the inventory of that product.
· Modify the output to display this additional feature you have chosen and the restocking
fee.
· Post as an attachment

I need help in understanding what it is I'm doing wrong!!! :confused:

// 7.6.08 Modified by Glen A. InventoryPart1.java

  import java.util.Scanner

  public class InventoryPart1 
  {

  public static void main( String args [])
  
     Dvd Movie[] = new Movie[4]; //Array declaration
  
     Movie[0] = new Movie("I'm", 01, $1.00);
     Movie[1] = new Movie("In", 02, $2.00);
     Movie[3] = new Movie("Hell" 03, $3.00);
     Movie[4] = new Movie("Help!" 04, $4.00);

   public class Dvd // Begins the class
   {

      private String dvdTitle; // title of the dvd movie
      private String dvdNumber; // the line item number of the movies
      private int itemInStock; // the number of movies the in house or in stock
      private double unitPrice; // price of the movie(s)
     
     // four constructor
     public InventoryPart1( String dvdTitle, String dvdNumber, int itemInStock, double UnitPrice)
  {

    
     // constructor calls to object at this point
     dvdTitle = title;
     dvdNumber = number;
     itemInStock = stock;
     setunitPrice( price ); // totaling price of units in stock
 

    // set product name
    public void setDvdTitle( String title )
    {
       dvdTitle = title;
    } // ends the method setDvdTitle

    // return dvd title
    public String getDvdTitle()
    {
       return dvdTitle;
    } // ends the method getDvdTitle

     // set dvd number
     public void setItemNumber( String Number )
     {
        itemNumber = Number;
     { // end method setItemNumber

     // return Item number
     public String getItemNumber()
     {
        return itemNumber;
     } // end method getProductName

      // set item in stock
      public void setItemInStock( String Stock )
      {
         itemInStock = stock; // items in my stock inventory
      } // end method setItemsInStock

      // return item in stock
      public String getItemInStock()
      {
         return itemInStock;
      } // end method getItemInStock

      // set unit price
      public void setUnitPrice( double price )
      {
          unitPrice = ( sales < 0 ) ? 0: units;
      } // end method setUnitPrice

      // return unit price
      public double getUnitPrice()
      {
         return unit price;
      } // end method getUnitPrice

      // set value
      public void setCostValue( double )
      {
         costValue = ( >= .0 && <= .0 ) ? : .0;
      } end method setCostValue

      // return cost value
      public double getCostValue()
      {
         return costVlaue;
      } // end method getCostValue

      // inventory price
      public double Unit()
      {
         return unitPrice * costTotal;
      } // end method inventory total

      private static void sortProductArray(objectName prodArray[])
      // method for the bubble sort
      {
          int flag = 0;
          // create a value to use as an indicator for  completion of the sort

          objectName temp; 
          // create a temporary object for sorting (class name)
 
          // enter a while loop to sort the array
 
      while (flag==0)
      {
         flag = 1;

         // enter a loop through the product array for sortin
      for ( int x = 0; x < prodArray.length - 1; ++x)
      {

      // see if thi s value is greater than the next
      if (prodArray[x].gtProdName().compareTo(prodArray[x+1}.getProdNmae()) > 0)
      {
         // switch this item an dthe next
         temp - prodArray[x];
	 prodArray[x] = prodArray[x+1];
         prodArray[x+1] = temp;

         // reset the flaf to 0
         flag = 0;
   
    } // end If
   } // end For loop
  } // end While loop
 } // end Sort method

      // return String InventoryPart1 object
      public String toString()
      {
         return String.format( "%s: %s %s\n%s: %.2f\n%s: %.2f",
            " inventory part1", productName, productNumber,
            " item in stock", itemInStock,
            " unit price". unitprice );

       public product(int item, String title, int stock, double price) {
          dvdItem = item;
          dvdTitle = title;
          dvdStock = stock;
          dvdPrice  = price;
    } //end four argument constructor

      } // end method toString

   } // end method InventoryPart1
2
Contributors
1
Reply
4
Views
9 Years
Discussion Span
Last Post by Alex Edwards
0

1) Please use Code Tags.

2) After just glancing through your project I noticed a huge error--

Movie[0] = new Movie("I'm", 01, $1.00);
Movie[1] = new Movie("In", 02, $2.00); 
Movie[3] = new Movie("Hell" 03, $3.00); // skipped Movie[2]
Movie[4] = new Movie("Help!" 04, $4.00); // null pointer exception
temp - prodArray[x]; // not a statement - you probably meant = for assignment
prodArray[x] = prodArray[x+1];
prodArray[x+1] = temp;
// Where do I start...
if (prodArray[x].gtProdName().compareTo(prodArray[x+1}.getProdNmae()) > 0)

// gtProdName() not declared - you probably meant getProdName() (refer to your above method)

// compareTo(prodArray[x+1) - missing ] after one

// compareTo(profArray[x+1} - } is being used instead of )

// .getProdNmae() - not declared - you probably mean getProdName() (refer to your above method)
// declared but never defined
private String dvdTitle; // title of the dvd movie
private String dvdNumber; // the line item number of the movies
private int itemInStock; // the number of movies the in house or in stock
private double unitPrice; // price of the movie(s)


// four constructor
public InventoryPart1( String dvdTitle, String dvdNumber, int itemInStock, double UnitPrice)
{


// constructor calls to object at this point
dvdTitle = title;
dvdNumber = number;
itemInStock = stock;
setunitPrice( price ); // totaling price of units in stock

// ...

// No end to Constructor InventoryPart1 - missing }

// attempting to assign local variables with undeclared variables.

// call to undeclared method setunitPrice - you probably mean setUnitPrice (case sensitive)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.