Java 为什么每个产品都是';s";体裁;运行此操作时,输出上是否未显示? 你能发布DVD课程吗?为什么你在DVD课程中间有DVD p1到P5的所有数据?是的,那不应该在那里。 public class DVD implements Compara

Java 为什么每个产品都是';s";体裁;运行此操作时,输出上是否未显示? 你能发布DVD课程吗?为什么你在DVD课程中间有DVD p1到P5的所有数据?是的,那不应该在那里。 public class DVD implements Compara,java,Java,为什么每个产品都是';s";体裁;运行此操作时,输出上是否未显示? 你能发布DVD课程吗?为什么你在DVD课程中间有DVD p1到P5的所有数据?是的,那不应该在那里。 public class DVD implements Comparable<DVD> { int dvdNumber; String dvdName; int quantity; double price; /* *This

为什么每个产品都是';s";体裁;运行此操作时,输出上是否未显示?
你能发布DVD课程吗?为什么你在DVD课程中间有DVD p1到P5的所有数据?是的,那不应该在那里。
public class DVD implements Comparable<DVD>
{ 
     int dvdNumber; 
     String dvdName;
     int quantity; 
     double price;


     /*  
      *This constructor takes the dvdNumber as string, the dvdName as string, a quantity as integer, and a price as a double and sets the base values of the items(s) in inventory 
      */ 
     public DVD(int number, String name, int quantity, double MSRP) 
     { 
          dvdNumber = number; 
          dvdName = name;
          this.quantity = quantity; 
          price = MSRP; 
     } 
     // getdvdNumber: returns the identifier for the item 
     public int getdvdNumber() 
     { 
          return dvdNumber; 
     } 
     // setdvdNumber: sets the identifier for the item 
     public void setdvdNumber(int value) 
     { 
          dvdNumber = value; 
     } 
     // getdvdName: returns the item name for the item 
     public String getdvdName() 
     { 
          return dvdName; 
     }      

     // getQuantity: returns the quantity of dvds in stock 
     public int getQuantity() 
     { 
          return quantity; 
     } 

     // setQuantity: sets the number of dvds in stock 
     public void setQuantity(int value) 
     { 
          quantity = value; 
     } 

     // getPrice: returns the price for the dvd
     public double getPrice() 
     { 
          return price; 
     } 
     // setPrice: sets the price for the dvd 
     public void setPrice(double value) 
     { 
          price = value; 
     } 
     // getInventoryValue: calculates the total value of the inventory for the item 
     public double getInventoryValue() 
     { 
          return getPrice() * getQuantity(); 
     } 
     // toString returns the printout of the individual item for display to the screen 
     public String toString() 
     { 
          return String.format("\nInventory Info\n%s %s\n%s\t %s\n%s\t %d\n%s\t $%,.2f\n%s\t $%,.2f","Product Number: ", getdvdNumber(), 
                    "Product Name: ", getdvdName(), "Units In Stock:", getQuantity(), 
                    "Price per Unit:", getPrice(), "Total Inventory Value:", getInventoryValue()); 
     }

        @Override
        public int compareTo(DVD other){
            int last = this.dvdName.compareTo(other.dvdName);
            return last == 0 ? this.dvdName.compareTo(other.dvdName) : last;
            }

} // end class DVD
class DVD2 extends DVD {
    private String dvdGenre;

    public DVD2(int number, String name, String genre, int quantity, double price)
    {
        super(number, name, quantity, price);
        dvdGenre = genre;
    }

    public String getdvdGenre()
    {
        return dvdGenre;
    }

    DVD p1 = new DVD2(1,"Forrest Gump","Drama",3,15.49);
    DVD p2 = new DVD2(2,"Cast Away","Adventure",7,17.29);
    DVD p3 = new DVD2(3,"The Interview","Comedy",9,19.99);
    DVD p4 = new DVD2(4,"Fight Club","Drama",5,14.79);
    DVD p5 = new DVD2(5,"Happy Gilmore","Comedy",16,9.29);

    public double value() {
        double value = getPrice() * getQuantity();
        value = 0.05 * value;
        return value;
    } // end method value

    @Override public String toString()
    { 
        return String.format("\nInventory Info\n%s %s\n%s\t %s\n%s\t %d\n%s\t $%,.2f\n%s\t $%,.2f","Product Number: ", getdvdNumber(), 
              "Product Name: ", getdvdName(), "Genre: ", getdvdGenre(), "Units In Stock:", getQuantity(), 
              "Price per Unit:", getPrice(), "Total Inventory Value:", getInventoryValue()); 
    }

} // end class DVD2