Inventory Program part 3

Inventory Program part 3

Page 1 of 1

1 Replies - 4143 Views - Last Post: 30 August 2010 - 09:18 PM Rate Topic: -----

#1 fr0styh3rb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-August 10

Inventory Program part 3

Posted 30 August 2010 - 09:07 PM

Hello, I am having trouble trying to compile my Inventory Program phase 3. My program outputs the "welcome to the inventory program part 3", conducts inventory value, and outputs thank you for using the inventory program. I am having trouble implementing an array to store information and retreive the data. If someone could take a look and let me know what I am doing inaccurately I would very much greatly appreciate it. Thanks for your help.


// Fig 3.0: Inventory.java
// This program calculates inventory value

import java.util.Scanner;
import java.util.Arrays;

public class Inventory
{

     // main method begins program execution
     public static void main(String args[] )
     {
          // create Scanner to obtain input from command window
          Scanner input = new Scanner( System.in );

          // display a welcome message to the InventoryProgramPart3 user
          System.out.println( "Welcome to Inventory Program Part 3!" );

          // Camera Inventory

          Camera[] myCamera = new Camera[100]; // an array of 3 cameras


          myCamera[0] = new Camera(0,"Sony",4000, 60, 200.00 );
          myCamera[1] = new Camera(1,"Toshiba",3000, 50, 150.00 );
          myCamera[2] = new Camera(2,"Phillips",2000, 40, 100.00 );

          // display the inventories one at a time

         

          // sort cameras by name
          for ( int i = 0; i < args.length; i++ )
          System.out.println( args[i] + ", " );

          double array[] = { 100.00, 150.00, 200,00 };
          double total = 0;

          // add each element's value to total
          for ( int counter = 0; counter < array.length; counter++)
               total += array[ counter ];
          System.out.printf( "\nTotal inventory value is: $%.2f\n", total );

          System.out.println( "\nThank you for using Inventory Program Part 3!\n" );

     } // end method main

    private Inventory() {
    }

    void showInventory() {

    }

    double getValue() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    double getPrice() {
        throw new UnsupportedOperationException("Not yet implemented");
    }


} // end class Inventory



class Camera
{

    private static String getCameraManufacturer() {
        throw new UnsupportedOperationException("Not yet implemented");
    }
     private String UnitName = new String();
     private int UnitNumber;
     private int NumberofUnits;
     private double UnitPrice;

    Camera(int i, String string, int i0, int i1, double d) {
       
    }

     // set supplies number
     public void setUnitName( String Name )
     {
          this.UnitName = Name;
     } // end method set unit name

     // return unit name
     public String getUnitName()
     {
          return UnitName;
     } // end method get unit name

     // set supplies name
     public void setUnitNumber( int Number)
     {
          this.UnitNumber = Number;
     } // end method set unit number

     // return unit number
   

     // set number of units
     public void setNumberofUnits( int Units )
     {
          this.NumberofUnits = Units;
     } // end method set number of units

     // return number of units
     public int getNumberofUnits()
     {
          return NumberofUnits;
     } // end method get number of units

     // set unit price
     public void setUnitPrice( double price )
     {
          this.UnitPrice = price;
     } // end method set unit price

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

     // calculate unit price inventory value
     public double getValue()
     {
          return getNumberofUnits() * getUnitPrice();
     } // end method camera inventory value

    public Camera(int UnitNumber, int NumberofUnits, double UnitPrice) {
        this.UnitNumber = UnitNumber;
        this.NumberofUnits = NumberofUnits;
        this.UnitPrice = UnitPrice;
    }

    // four-argument constructor

     Camera( String Name, int Number, int Units, double Price )
     {
          UnitName = Name;
          UnitNumber = Number;
          NumberofUnits = Units;
          UnitPrice = Price;
     } // end four-argument constructor

    // display inventory
     public void showInventory()
     {
          System.out.println(); // outputs blank line

          System.out.println( "Product Name:  "+getUnitName() );
          System.out.println( "Product Number:  "+getUnitNumber() );
          System.out.println( "Units in Stock:  "+getNumberofUnits() );
          System.out.printf( "Unit Price:  $%.2f", getUnitPrice());

         
               

          System.out.println( "\nManufacturer:  "+Camera.getCameraManufacturer() );

          // value() method and display the value
          System.out.printf( "\nInventory value of "+getUnitName()+ " is = $%.2f\n",
               getValue() );

    } // end display inventory

    private String getUnitNumber() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

} // end class Camera



 class InventoryProgram extends Inventory

{
     // holds the Camera manufacturer
     private String CameraManufacturer;

     // five-argument constructor
     InventoryProgram( String Name, int Number, int Units,
          double price, String manufacturer )
     {
          super(Name, Number, Units, Price, manufacturer);
          CameraManufacturer = manufacturer;
     } // end five-argument constructor

     // set camera manufacturer
     public void setCameraManufacturer( String manufacturer )
     {
          this.CameraManufacturer = manufacturer;
     } // end method set camera manufacturer

     // return camera manufacturer
     public String getCameraManufacturer()
     {
         return CameraManufacturer;
     } // end method get camera manufacturer

     // add 5% restocking fee

    @Override
     public double getPrice()
     {
          return super.getValue() * 1.05;
     } // end method return camera manufacturer

     // calculate restocking fee
     public double getRestockingFee()
     {
          return super.getValue() * .05;
     } //end method calculate restocking fee

     //return String representation of CameraManufacturer
    @Override
     public String toString()
     {
          String formatString = "Manufacturer:  %s";
          formatString += "Restocking Fee:  $%.2f";
          formatString = String.format( formatString, CameraManufacturer,
               super.getPrice() * 0.05 );
          return( formatString + super.toString() );
     } // end toString()

     // display inventory

     public void showInventory(String showInventory, String CameraName)
     {
          super.showInventory();
          System.out.println( toString() );
          System.out.println( "\nManufacturer:  "+getCameraManufacturer() );

          // Display value plus restocking fee
          System.out.printf( "\nInventory value of "+CameraName+ " is = $%.2f\n",
               getRestockingFee() );

     } // end method display inventory

} // end class manufacturer

This post has been edited by fr0styh3rb: 30 August 2010 - 09:54 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Inventory Program part 3

#2 b0ng01  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 38
  • View blog
  • Posts: 169
  • Joined: 16-July 10

Re: Inventory Program part 3

Posted 30 August 2010 - 09:18 PM

I didn't go through and look for all the problems but this one jumped out.
 InventoryProgram( String Name, int Number, int Units,
          double price, String manufacturer )
     {
          super(Name, Number, Units, Price );
          CameraManufacturer = manufacturer;
     } // end five-argument constructor



Your Inventory super class does not have a constructor that takes any arguements. Even excluding that, you bring in price, but send over Price to your super. It looks like you are trying to call your camera's constuctor, but you are not extending camera you are extending Inventory.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1