0

I am not sure how to explain the issue that I am having. I believe that I am successful with the exception of this part of the assignment and I have been working on this for hours and need help. This is what I am having trouble with:In the subclass, create a method to calculate the value of the inventory of a product with the same name as the method previously created for the product class.
The subclass method should also add a 5% restocking fee to the value of the inventory of that product
This is my code so far from previous assignments.

package inventory;



import java.util.*;

public class inventory {

    static DVD2Disk []dvd;

    public static void main(String[] args) {
        int Tot = 10;
        dvd = new DVD2Disk[10];

        dvd[0] = new DVD2Disk(1,"The Notebook",5,13.99,1);
        dvd[1] = new DVD2Disk(2,"The Ugly Truth",10,14.99,1);
        dvd[2] = new DVD2Disk(3,"Shutter Island",25,17.99,2);
        dvd[3] = new DVD2Disk(4,"Away We Go",13,15.99,1);
        dvd[4] = new DVD2Disk(5,"Definitely Maybe",19,11.99,2);
        dvd[5] = new DVD2Disk(6,"Good Will Hunting",17,12.99,1);
        dvd[6] = new DVD2Disk(7,"Mystic River",15,14.50,2);
        dvd[7] = new DVD2Disk(8,"Before Sunset",18,20.00,1);
        dvd[8] = new DVD2Disk(9,"New Moon",7,16.99,2);
        dvd[9] = new DVD2Disk(10,"Up in the Air",9,18.99,1);

        for(int i=0;i<Tot;i++)
            dvd[i].printInfo();

        DVDcompa D = new DVDcompa();

        Arrays.sort(dvd,D);

            //Sorting using the custom Comparator class

        double sum = 0;
        for(int i=0;i<Tot;i++)
            sum += (dvd[i].getStock()*dvd[i].getPrice());

        System.out.println("Total Value of the Entire Inventory : "+sum+"\n");

        System.out.println("The Items in the Sorted Order");
        System.out.println("----------------------------------------------------");

        for(int i=0;i<Tot;i++)
            dvd[i].printInfo();
    }
}
 package inventory;

public class DVD  {
    private int dvdItem;
    private String dvdTitle;
    private int dvdStock;
    private double dvdPrice;

    public DVD(int I,String T,int S, double P)
    {
        dvdItem = I;
        dvdTitle = T;
        dvdStock = S;
        dvdPrice = P;
    }

    public int getItem()
    {
        return dvdItem;
    }

    public String getTitle()
    {
        return dvdTitle;
    }

    public int getStock()
    {
        return dvdStock;
    }

    public double getPrice()
    {
        return dvdPrice;
    }

    public void setItem(int I)
    {
        dvdItem = I;
    }

    public void setTitle(String T)
    {
        dvdTitle = T;
    }

    public void setStock(int S)
    {
        dvdStock = S;
    }

    public void setPrice(double P)
    {
        dvdPrice = P;
    }


    public void printInfo()
    {
        System.out.println("The Item Number is : "+dvdItem);
        System.out.println("The Title is : "+dvdTitle);
        System.out.println("The Number of items in Stock is : "+dvdStock);
        System.out.println("The Price is : "+dvdPrice);
        System.out.println("The Total Cost is : "+dvdStock*dvdPrice);
        System.out.println("----------------------------------------------------");
    }


}
package inventory;

/**
 *
 * @author Julie
 */
public class DVD2Disk extends DVD {
     int diskCount;
      public DVD2Disk(int I,String T,int S, double P, int diskCount){
           super(I, T, S, P);
             this.diskCount = diskCount;

}

    public void setDiskCount(int diskCount) {
        this.diskCount = diskCount;
    }

    public int getDiskCount() {
        return diskCount;
       }

    public double fee(){
        if (diskCount>1)
            return .05;
        else return 0;
    }
    fee += (dvd[i].getPrice()* fee .05);


    public void printInfo(){

        System.out.println("The Number of disks is : "+diskCount);
            super.printInfo();

    }
}

I am using NetBeans if that helps can anyone tell me what I am doing wrong or what I need to do.

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by jwenting
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.