collapse collapse

* Recent News

Fifth Matrix Film Announced! by Lithium
[January 29, 2025, 03:37:07 pm]


Meta Connect 2024 by Tbone
[September 25, 2024, 01:37:22 pm]


Quest Headsets Will No Longer Require Facebook Account by Tbone
[July 07, 2022, 03:17:21 pm]


New Matrix Online? "Matrix Awakens" UE5 Demo by Tbone
[December 28, 2021, 01:05:59 pm]

* Recent Posts

randomness by Lithium
[March 05, 2025, 01:40:53 pm]


Fifth Matrix Film Announced! by Lithium
[January 29, 2025, 03:37:07 pm]


Holiday Fun by Jeyk
[January 03, 2025, 11:41:50 am]


FA in DC? by Subb
[November 01, 2024, 03:55:27 pm]


Meta Connect 2024 by Tbone
[September 25, 2024, 01:37:22 pm]


2024: New PC for VR! by Tbone
[April 06, 2024, 12:22:30 pm]


MOVED: Fifth Matrix Film Announced! by Tbone
[April 06, 2024, 12:18:27 pm]


Quest 2 Link Best Settings (Finally Better Than Rift S) by Tbone
[November 27, 2023, 04:57:46 pm]

Author Topic: Java Project  (Read 2488 times)

Offline Heironymus

  • Angelic Fury
  • ******
  • Join Date: May 2005
  • Posts: 1488
    • View Profile
    • http://www.xanga.com/Inner_Fatman
Java Project
« 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.

Offline Ash

  • VETERAN ANGEL
  • *******
  • Join Date: Jul 2005
  • Posts: 1691
    • View Profile
Re: Java Project
« Reply #1 on: October 07, 2007, 05:04:12 pm »
I would if I could bro.  Hopefully someone here can help.

"Do not pray for easy lives. Pray to be stronger men"

Offline Anamodiel

  • Staff
  • *******
  • Join Date: Mar 2006
  • Posts: 3735
    • View Profile
Re: Java Project
« Reply #2 on: October 07, 2007, 05:04:50 pm »
I've never been good with Java. I'm so sorry. :(


...And we will strike down upon those of Darkness, with great vengeance and Furious Anger, those who attempt to poison and destroy my brothers.

 

 

* Discord

Calendar

April 2025
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
[20] 21 22 23 24 25 26
27 28 29 30

No calendar events were found.

* Who's Online

  • Dot Guests: 153
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

Social