My assignment is as follows;
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 product class that holds the item number, the name of the product, the number of units in stock, and the price of each unit.
• Create a Java application that displays the product number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory (the number of units in stock multiplied by the price of each unit). Pay attention to the good programming practices in the text to ensure your source code is readable and well documented.
Here is what I have so far
Expand|Select|Wrap|Line Numbers
- /**
- *@author Greg Hamilton
- *Program was changed 31 Aug 07
- *The purpose of this program is to create a product class that holds an item number, name of the DVD movie, number of units in stock
- *and the price of each unit
- */
- import java.util.Scanner;
- import java.io.*;
- import java.util.*;
- public class Dvd extends Object
- {
- private String dvdTittle;
- private double dvdStock;
- private double dvdPrice;
- private double dvdItem;
- public Dvd( String tittle, double stock, double price, double item )
- {
- //implicit call to Object constructor occurs here
- dvdTittle = tittle;
- dvdStock = stock;
- dvdPrice = price;
- dvdItem = item;
- } //end four-argument constructor
- //set DVD name
- public void setdvdTittle( String tittle )
- {
- dvdTittle = tittle;
- } //end method setDvdTittle
- //return dvd Tittle
- public String getDvdTittle()
- {
- return dvdTittle;
- } //end method getDvdTittle
- //set Dvd stock
- public void setDvdStock( double stock)
- {
- dvdStock = ( stock < 0.0 ) ? 0.0 : stock;
- } //end method setDvdStock
- //return dvd stock
- public double getDvdStock()
- {
- return dvdStock;
- } //end method getDvdStock
- public void setDvdPrice( double price )
- {
- dvdPrice = ( price <0.0 ) ? 0.0 : price;
- } //end method SetDvdPrice
- //return dvd price
- public double getDvdPrice()
- {
- return dvdPrice;
- } //end method get Dvd Price
- public void setDvdItem( double item )
- {
- dvdItem = ( item <0.0) ? 0.0 : item;
- } //end method set dvd Item
- //return dvd item
- public double getDvdItem()
- {
- return dvdItem;
- } //end method getDvdItem
- // calculate inventory value
- public double value()
- {
- return dvdPrice * dvdStock;
- } //end method value
- //instantiate Collection object
- Dvd aDvd= new Dvd ("Dejavu", "10", "12.50", "101");
- public static void main( String args[] )
- {
- System.out.printf("%s %s\n", "Product Tittle is",
- Dvd.gettittle() );
- System.out.printf("%s %s\n", "The number of units in stock is",
- Dvd.getstock() );
- System.out.printf("%s %s\n", "The price of each DVD is",
- Dvd.getprice() );
- System.out.printf("%s %s\n", "The item number is",
- dvd.getitem() );
- System.out.printf("%s %s\n", "The value of the inventory is",
- Dvd.getvalue() );
- } //end main
- } //end class Dvd
My complier does not like my Dvd aDVD = new Dvd(); statement. I filled in values to populate the data points required for the program.
The error codes that I get are as follows;
6 errors found:
File: C:\Documents and Settings\Greg\Desktop\Dvd.java [line: 90]
Error: C:\Documents and Settings\Greg\Desktop\Dvd.java:90: cannot find symbol
symbol : constructor Dvd(java.lang.String,java.lang.String,java.lang.St ring,java.lang.String)
location: class Dvd
File: C:\Documents and Settings\Greg\Desktop\Dvd.java [line: 102]
Error: C:\Documents and Settings\Greg\Desktop\Dvd.java:102: cannot find symbol
symbol : method gettittle()
location: class Dvd
File: C:\Documents and Settings\Greg\Desktop\Dvd.java [line: 104]
Error: C:\Documents and Settings\Greg\Desktop\Dvd.java:104: cannot find symbol
symbol : method getstock()
location: class Dvd
File: C:\Documents and Settings\Greg\Desktop\Dvd.java [line: 106]
Error: C:\Documents and Settings\Greg\Desktop\Dvd.java:106: cannot find symbol
symbol : method getprice()
location: class Dvd
File: C:\Documents and Settings\Greg\Desktop\Dvd.java [line: 108]
Error: C:\Documents and Settings\Greg\Desktop\Dvd.java:108: cannot find symbol
symbol : variable dvd
location: class Dvd
File: C:\Documents and Settings\Greg\Desktop\Dvd.java [line: 110]
Error: C:\Documents and Settings\Greg\Desktop\Dvd.java:110: cannot find symbol
symbol : method getvalue()
location: class Dvd
Thanks for any help that you can give me.