Member Avatar for ScottShip

Hi, I have follen behind on my inventory program. If I send what I have, can someone please help me finish it? I am on part 4 but part 3 is not finished as I am lost.

Member Avatar for ScottShip

I really need some help; like yesterday! Please??

Post your (relevant) code, and explain your problem.

Member Avatar for ScottShip

Here are my instructions up to part 4. I will post them seperately so you know exactly what I have to do.

Member Avatar for ScottShip

Choose a product that lends itself to an inventory (for example, products at your workplace, office supplies, music CDs, DVD movies, or software).

Create a class named after the product you have chosen that holds the item number, the name of the product, the number of units in stock, and the price of each unit. Make sure this class includes get and set methods for each of the attributes above.
For Example:
If your product is shoes, make your product class Shoe.java etc.

Important Note:
We are preparing to create a GUI class, so the command line features will start to go away, starting with data input. When you create your instance of your product class, just give it some hard coded values. Do not prompt the user for data.
Post your source code.

2 files required:

Inventory.java
<Your Product Name>.java

Member Avatar for ScottShip

Check Point: Inventory Program Part 2
Resource: Java: How to Program Chapter 7, Programming Tip – Naming Conventions – Main Thread, Programming Tip – Arrays vs. ArrayLists – Main Thread.
Modify the Inventory Program so the application can handle multiple items. Use an ArrayList to store the items. DO NOT PROMPT USER FOR INPUT; initialize the array with hard coded values.
The output should display the information the first product in your ArrayList, 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.
Create a method to calculate the value of the entire inventory. Call this method and display the results. (Hint: Use a loop to make your calculation.)
Create another method to sort the array items by the name of the product.
Post your source code.
2 files required:
Inventory.java
<Your Product Name>.java

Member Avatar for ScottShip

Check Point: Inventory Program Part 3

Resource: Java: How to Program Chapters 9 and 10.

Modify the Inventory Program by creating a subclass of the product class that uses one additional unique attribute of the product you chose (for example, if Movie is your product, you can create a subclass named ForiegnMovie with “country” as a unique attribute).
In the subclass, override the method to calculate the value of the inventory of a product with the same name and return type as the method previously created for the product class. The subclass override should add a 5% restocking fee to the value of the product.
Modify the output to display this additional attribute you have chosen and the restocking fee.

Post your source code.

3 files required:

Inventory.java
<Your Product Name>.java
<Your Subclass Name>.java

congratulations ScottShip: you managed to copy paste your assignment. I hope you don't expect us to be to impressed by that show of skill.

Member Avatar for ScottShip

Check Point: Inventory Program Part 4

Resource: Java: How to Program Chapter 11, Naming Conventions – Main Thread.

Modify the Inventory Program to use a GUI by either
Adding a new class that extends JFrame (example in Chapter 11), or
By creating a new JDeskTop Application project.
Use an ArrayList or other automatically resizable collection instead of an Array to store your products.
The GUI should display the information of the first product in your collection, 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. Since this requires a loop of your collection, out this functionality in a separate method of your GUI class. This will allow you to call it only when updating the total is required.
At this point, all your main method should do is create an instance of your GUI class, set the Window size, setDefaultCloseOperation to EXIT_ON_CLOSE, start the GUI by calling it’s show method and get out of the way. (Desktop app will do this for you).
The Collection of products now belongs to the GUI class as a class level variable. This will allow all methods in the GUI class to have access to it.
If you use the Desktop Application, it will create a read-only method named initComponents. As you drag components to the screen, initialization code for them will be added to this method. The method is then called from your GUI constructor. Things you add manually, like your collection cannot go in this method. You need to initialize them in the constructor yourself.

Do not use a series of pop-up dialog boxes. A GUI is a single screen that gives you access to all of the applications functionality. Pop-ups can be used for prompts, and when needed to collect specific data. But if you need values for 4 variables, use a single pop-up with four fields, not one popup per variable.

Post a zipped copy of the entire project.

Member Avatar for ScottShip

It will not let me send my code

Member Avatar for ScottShip
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author robert
 */
public class Cd implements Comparable<Cd> {

    protected String cdTitle;
        protected Integer itemNumber;
            protected Integer cdsInStock;
                protected Double pricePerCd;
                    protected String artists;
                        protected double totalInventory;

    public Cd(String cdTitle, Integer itemNumber, Integer cdsInStock, Double pricePerCd) {
        this.cdTitle = cdTitle;
        this.itemNumber = itemNumber;
        this.cdsInStock = cdsInStock;
        this.pricePerCd = pricePerCd;
        this.artists = artists;
        this.totalInventory =totalInventory;


    }

    public String getCdTitle() {
        return cdTitle;
    }

    public void setCdTitle(String cdTitle) {
        this.cdTitle = cdTitle;
    }

    public Integer getItemNumber() {
        return itemNumber;
    }

    public void setItemNumber(Integer itemNumber) {
        this.itemNumber = itemNumber;
    }

    public Integer getCdsInStock() {
        return cdsInStock;
    }

    public void setCdsInStock(Integer cdsInStock) {
        this.cdsInStock = cdsInStock;
    }

    public Double getPricePerCd() {
        return pricePerCd;
    }

    public void setPricePerCd(Double pricePerCd) {
        this.pricePerCd = pricePerCd;
    }
    public String getArtists(){
        return artists;
    }
    public void setArtists(String artists){
        this.artists= artists;
    }
    public Double getTotalInventory(){
        return totalInventory;
    }
    public void setTotalInventory(){
        this.totalInventory=totalInventory;
    }
 public int compareTo(Cd cd){
    Cd inputParameter = (Cd)cd;
    return cdTitle.compareTo(inputParameter.cdTitle);   
    }
 calculate totalPrice = 




Cd inputParameter = (Cd)cd;
return cdTitle.compareTo(inputParameter.cdTitle);   
}

calculate totalPrice =

Member Avatar for ScottShip
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author robert
 */
public class MusicCd extends Cd{

protected String artists;

    public MusicCd(String cdTitle, String artist, Integer itemNumber, Integer cdsInStock, Double pricePerCd  ){

        super(cdTitle, itemNumber, cdsInStock, pricePerCd);
        this.artists = artist;


    }//end constructor


    public Double getTotalInventory(){
            return this.cdsInStock * this.pricePerCd ;
                    }
    //override to include stocking fee
    //getter setter

    @Override
    public Integer getCdsInStock(){
        return this.(); //To change body of generated methods, choose Tools | Templates.
    }

}
Member Avatar for ScottShip
import java.util.ArrayList;
import java.util.Collections;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author robert
 */
public class Inventory2 {



    /**
     * @param args the command line arguments
     */
public static void main(String[] args) {
        // TODO code application logic here

MusicCd[] arrayList = new MusicCd[9];

        arrayList[0] = new MusicCd("DavidLeeRoth" ,"VanHalen", 1, 100, 20.55);

        arrayList[1] = new MusicCd("BradDelp", "Boston", 2, 300, 15.79);

        arrayList[2] = new MusicCd("JohnLennon,PaulMcCartney,GeorgeHarrison,RingoStarr","TheBeatles", 3, 125, 12.00);

        arrayList[3] = new MusicCd("Roger Daltrey","TheWho", 4, 130, 20.39);

        arrayList[4] = new MusicCd("Dave Evans,Bon Scott,Brian Johnson","ACDC", 6, 120, 23.25);

        arrayList[5] = new MusicCd("Mick Jagger,Keith Richards","TheRollingStones", 7, 32, 22.50);

        arrayList[6] = new MusicCd("Mike Love","TheBeachBoys", 8, 30, 24.00);

        arrayList[7] = new MusicCd("James Hetfield","TheBestOfMetallica", 9, 308, 45.00 );

//
        ArrayList<MusicCd> music = new ArrayList<>();
            for(MusicCd cd : arrayList) {
            music.add(cd);
            music.get(0).getCdTitle();
//create display message
    }

//create static void method!
        static void sortMusicCd(ArrayList <MusicCd> music){
            Collections.sort(music);
            }
     }
Member Avatar for ScottShip

Just need to make this work up to part 4. Then I should be in a good spot to implement my GUI interface.

and ... what is the part that is not working?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.