The Furious Angels

FA Discussion => Off Topic => Topic started by: Heironymus on October 07, 2007, 04:57:13 pm

Title: Java Project
Post by: Heironymus on October 07, 2007, 04:57:13 pm
So guys, I am in a seriously tight spot. I have a project due at midnight tonight, am leaving for work and won't be home until 11:30. I already have half of it completed and the last half I am completely lost. I figured I would post what I have of the code.. what needs to be finished and see if you guys could help me out. I would be more than happy to compensate the person or persons for there help. I hate doing this because it is a my project but I am lost and have severe time constraints.

CheckPoint: Inventory Program Part 4
• Modify the Inventory Program to use a GUI. The GUI should display the information one
product at a time, including the item number, the name of the product, the number of
units in stock, the price of each unit, and the value of the inventory of that product. In
addition, the GUI should display the value of the entire inventory, the additional attribute,
and the restocking fee.

CheckPoint: Inventory Program Part 5
• Modify the Inventory Program by adding a button to the GUI that allows the user to move
to the first item, the previous item, the next item, and the last item in the inventory. If the
first item is displayed and the user clicks on the Previous button, the last item should
display. If the last item is displayed and the user clicks on the Next button, the first item
should display.
• Add a company logo to the GUI using Java graphics classes.

Final Project: Inventory Program Part 6
• Modify the Inventory Program to include an Add button, a Delete button, and a Modify
button on the GUI. These buttons should allow the user to perform the corresponding
actions on the item name, the number of units in stock, and the price of each unit. An
item added to the inventory should have an item number one more than the previous last
item.
• Add a Save button to the GUI that saves the inventory to a C:\data\inventory.dat file.
• Use exception handling to create the directory and file if necessary.
• Add a search button to the GUI that allows the user to search for an item in the inventory
by the product name. If the product is not found, the GUI should display an appropriate
message. If the product is found, the GUI should display that product's information in the
GUI.

Thats what still needs to be done...

This is my code.
Code: [Select]
//Steven Putman

import java.util.Arrays;

public class Inventory3
{
    public static void main( String args[] )
    {
      double totalInventoryValue = 0.0;

System.out.println("\nInventory Week 6: Inventory Program 3\n");

      Book [] inventory;
      inventory = new Book[3];

      inventory[0] = new Book("Confederacy of Dunces", "Toole, John", 1, 150, 9.99);
      inventory[1] = new Book("Hitchhiker's Guide to the Galaxy, The", "Adams, Douglas", 2, 250, 35.99);
      inventory[2] = new Book("Memoirs of a Geisha", "Golden, Arthur", 3, 400, 15.99);

      Arrays.sort( inventory );

      for (Book book:inventory)
      {

          System.out.println( book.toString() );

      }

      totalInventoryValue = Product.totalInventoryValue( inventory );

      System.out.printf( "Total Inventory Value : $%.2f\n", totalInventoryValue );

     }

}


Code: [Select]

public class Book extends Product implements Comparable
{

    private String author;

    public Book(String titleIn, String authorIn, int idIn, int unitsInStockIn, double unitPriceInDollarsIn)
    {
        super( titleIn, idIn, unitsInStockIn, unitPriceInDollarsIn);
        setAuthor( authorIn );
    }
        public void setAuthor( String authorIn )
        {
            author = authorIn;

        }

         public String getAuthor()
         {
             return ( author );
         }
        public double stockValueInDollars()
        {
          return(super.stockValueInDollars() * 1.05);
        }
        public double restockingFee()
        {
            return( super.stockValueInDollars() * 0.05 );
         }
        public String toString()
        {
                String formatString         = "Author                  : %s\n";
                formatString               += "Restocking Cost         : $%.2f\n";

                formatString = String.format(formatString, author, restockingFee() );

                return( formatString + super.toString() );
         }
    }


Code: [Select]

public class Product implements Comparable
{

    private String name;
    private int idNumber;
    private int productInStock;
    private double productPriceInDollars;

    public Product()
    {
        name                  = "";
        idNumber    = 0;
        productInStock          = 0;
        productPriceInDollars    = 0.0;
    }
    public Product( String nameIn, int idNumberIn,
                    int productInStockIn, double productPriceInDollarsIn )
    {
        setName( nameIn );

        setIdNumber( idNumberIn );

        setProductInStock( productInStockIn );

        setProductPriceInDollars( productPriceInDollarsIn );
    }
    public void setName( String nameIn )
    {
        name = nameIn;
    }
    public void setIdNumber( int idNumberIn )
    {
        idNumber = ( (idNumberIn > 0) ? idNumberIn : 0 );
    }
    public void setProductInStock( int productInStockIn )
    {
        productInStock = ( (productInStockIn > 0)?productInStockIn:0 );
    }
    public void setProductPriceInDollars( double productPriceInDollarsIn )
    {
        productPriceInDollars = ( (productPriceInDollarsIn > 0.0)?productPriceInDollarsIn:0.0);
    }
    public String getName()
    {
        return ( name );
    }
    public int getIdNumber()
    {
        return ( idNumber );
}
    public int getProductInStock()
    {
        return( productInStock );
    }
    public double getProductPriceInDollars()
    {
        return( productPriceInDollars );
    }
    public double stockValueInDollars()
    {
        return ( productInStock * productPriceInDollars );
    }
//Steven Putman

    public static double totalInventoryValue( Product inventory[] )
    {
      double value = 0.0;
      for(Product p: inventory)
      {
       value += p.stockValueInDollars();
      }
      return( value );
    }
    public int compareTo (Object o)
    {
        String s2 = ((Product)o).name.toUpperCase();
        String s1 = name.toUpperCase();
        return ( s1.compareTo(s2) );
     }

    public String toString()
    {
        String formatString = "Id Number               : %d\n";
        formatString       += "Product Title           : %s\n";
        formatString       += "Product In Stock        : %d\n";
        formatString       += "Product Price           : $%.2f\n";
        formatString       += "Stock Value             : $%.2f\n\n";

        return ( String.format( formatString, idNumber, name, productInStock,
                                productPriceInDollars, stockValueInDollars()));
    }

}






Once again.. Thanks for any help you can give... I am lost on this stuff.. programming is not my thing.
Title: Re: Java Project
Post by: Ash on October 07, 2007, 05:04:12 pm
I would if I could bro.  Hopefully someone here can help.
Title: Re: Java Project
Post by: Anamodiel on October 07, 2007, 05:04:50 pm
I've never been good with Java. I'm so sorry. :(
SimplePortal 2.3.8 © 2008-2025, SimplePortal