Home | How it works | Projects archive | Contact Us
Air Compressor Bot
 
The Career Path of Freelance Programming Jobs 

   Inventory Project Modification

Bidding Time:
16/11/2007 22:29 - 19/11/2007 22:29
Budget:
$10-15
Status:
Closed

Job Type:
Java
Description:



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.
Here is my code from previous modification:

public class Main {
package dvdinventory;

import java.lang.reflect.Array;
/*
Main method: the program itself
*/
public static void main(String[] args) {

MyDVDs inventory = new MyDVDs(); // Create an inventory
inventory.sortByName(); // Sort it by name
int i;
for( i = 0; i < inventory.getCount(); ++ i ) { // for each item
Dvd dvd = inventory.getItem( i );
// Display the information. Note that it uses toString() and works
both for Dvd and xDVD
System.out.println( dvd.toString() );
}
// Display the total inventory value.
System.out.println( "TOTAL VALUE: $" + String.valueOf(
inventory.getTotalValue() ) );
// End of the program
} // main()
} // DvdInventory

/*
This class represents the inventory.
*/
class MyDVDs {

/*
The inventory is stored in the array. In this example the array is
initialized with
several items. One can add and change items here.
*/
private Dvd[] dvds = {
new xDVD("130177-0001", "Some movie", 10, 5.0, "Some
title" ),
new xDVD("130177-0002", "One more movie", 7, 7.0,
"Another title" ),
new xDVD("130177-0003", "The third one", 3, 11.0,
"Title for no.3" ),
new xDVD("130177-0004", "Fourth", 5, 14.0, "Title for
no.4" ),
new xDVD("130177-0005", "Fifth", 4, 5.0, "Title for
no.5" )
};

/*
The constructor. In this case it does nothing.
*/
public MyDVDs() {
}

/*
Get the number of items in the inventory
*/
public int getCount() {
return Array.getLength( dvds );
}

/*
Get an item with the specified index
*/
public Dvd getItem( int index ) {
return dvds[ index ];
}
/*
Count the total value of the inventory ( the sum of all items' values )
*/
public double getTotalValue() {
int i;
double total = 0.0;
for( i = 0; i < Array.getLength( dvds ); ++ i )
total += dvds[ i ].getValue();
return total;
}
/*
Sort the array by product name. The algorithm is so called "bubble sort" -
one of the simplest sort algorithms
*/
public void sortByName() {
int i, j;
for( i = 0; i < Array.getLength( dvds ) - 1; ++ i )
for( j = 1; j < Array.getLength( dvds ) - i; ++ j )
if( dvds[ j - 1 ].getProductName().compareTo( dvds[ j
].getProductName() ) > 0 ) {
Dvd tmp = dvds[ j - 1 ];
dvds[ j - 1 ] = dvds[ j ];
dvds[ j ] = tmp;
}
}
} // MyDVDs

/*
Class for a single item
*/
class Dvd {

/* Data members */
private String productNumber;
private String itemName;
private int numberofUnits;
private double priceperUnit;

/* The constructor. Initializes all data members by arguments */
public Dvd(String productNum, String productName, int quantity, double
unitPrice) {
productNumber = productNum;
itemName = productName;
numberofUnits = quantity;
priceperUnit = unitPrice;
}

/* Methods to get all data members' values */
public String getProductNumber() {
return productNumber;
}

public String getProductName() {
return itemName;
}

public int getNumberofUnits() {
return numberofUnits;
}

public double getPricePerUnit() {
return priceperUnit;
}

/* the method calculating a value */
public double getValue() {
return priceperUnit * numberofUnits;
}

/*
This overrides the Object's method toString() which converts the object
to a string
*/
public String toString() {
return "Number: " + productNumber
+ " Name: " + itemName
+ " Number of units: " + String.valueOf( numberofUnits )
+ " Price per unit: $" + String.valueOf( priceperUnit )
+ " Value: $" + String.valueOf( getValue() );
}
} // Dvd

/*
The subclass
*/
class xDVD extends Dvd {

/* Additional data member */
private String title;

/* The constructor */
public xDVD( String productNum, String productName, int quantity, double
unitPrice, String itemTitle ) {
super( productNum, productName, quantity, unitPrice );
title = itemTitle;
}

/* "Get" for an additional member */
public String getTitle() {
return title;
}

/* "toString" for this class */
public String toString() {
return "Title: " + title + " " + super.toString();
}

/* overriden "getValue" adding 5% */
public double getValue() {
return super.getValue() * 1.05;
}
} // xDVD

}

STOPzilla! Anti-Spyware Software

Related Projects:
Mod For Clip Share Script
Integrate DHL XML API / EasyShip with OsCommerce CRE Loaded shopping cart
Updates to my PHP site
Simple Css Fix Needed
Unique Hosting Site Design

This project is the proprietary information of . Click here to remove this project from OUR database.
Operating System:
N/A
Database System:
N/A
<<< back

Recent Projects Archive:

Thursday - Wednesday - Tuesday - Monday - Sunday - Saturday - Friday

View all freelance web projects

 
Home | Projects archive | RSS | Resources | Links | Contact Us © 2004-2009 ProjectsList.biz /0.057