List<directorName> listA = new ArrayList<directorName>(); //create array for Director name and restocking fee.
These are the compiling errors I receive:
dvd.java:39: cannot find symbol
symbol : method setdirname(java.lang.String)
location: class dvdInventory
dvdObject.setdirname(input.nextLine());
^
dvd.java:59: cannot find symbol
symbol : method getDirName()
location: class dvdInventory
System.out.printf("Directors name: " + listA.get(
^
dvd.java:69: cannot find symbol
symbol : method getRestockfee()
location: class dvdInventory
System.out.printf("Restocking fee: $" + listA.get(
^
dvd.java:145: cannot find symbol
symbol : variable dirname
location: class directorName
return this.dirname;
^
dvd.java:149: cannot find symbol
symbol : variable dirname
location: class directorName
this.dirname = dirname;
^
//import java.util.List; // program users class List.
//import java.util.ArrayList; // program users class ArrayList.
//import java.util.Scanner; // program users class Scanner.
import java.util.*;
public class dvd
{
public static void main(String args[]) // main method.
{
List<dvdInventory> listA = new ArrayList<dvdInventory>(); //create array dvd inventory.
//List<directorName> listB = new ArrayList<directorName>(); //create array for Director name and restocking fee.
//List<directorName> listA = new ArrayList<directorName>(); //create array for Director name and restocking fee.
boolean loop = false; // stop logic for while loop.
while (loop != true) // while loop to add dvd to array list.
{
dvdInventory dvdObject = new dvdInventory(); // set object.
Scanner input = new Scanner(System.in); // create Scanner to obtain input from command window.
System.out.println(" "); // create whitespace.
System.out.print("Enter DVD name or stop to quit: "); // prompt user for DVD name.
String dn = input.nextLine();
if (dn.equalsIgnoreCase("stop"))
{
System.out.printf("\n");
loop = true;
}
if (loop != true)
{
dvdObject.setName(dn);
System.out.print("Enter Director's name: "); // prompt user for Director's name.
//String dn = input.nextLine();
dvdObject.setdirname(input.nextLine());
System.out.print("Enter Product Number: "); // prompt user for product number.
dvdObject.setItemNumber(input.nextInt());
System.out.print("Enter the price per unit: "); // prompt user for price
dvdObject.setPrice(input.nextDouble());
System.out.print("Enter the inventory count: "); // prompt user for dvd count per title.
dvdObject.setStockQuantity(input.nextInt());
System.out.println(" "); // create whitespace.
dvdObject.setInvntval(dvdObject.getPrice(), dvdObject.getStockQuantity());
listA.add(dvdObject);
}
}
int a = listA.size() - 1;
int b;
for (b = 0; b <= a; b++)
{
//listA.sort();
listA.get(b);
System.out.printf("DVD name: " + listA.get(b).getName()); // display DVD name.
System.out.printf("\n");
System.out.printf("Directors name: " + listA.get(b).getDirName()); // display directors name.
System.out.printf("\n");
System.out.printf("DVD Product Number: " + listA.get(b).getItemNumber()); // display product number.
System.out.printf("\n");
System.out.printf("Unit price: " + listA.get(b).getPrice()); // display unit price.
System.out.printf("\n");
System.out.printf("Total inventory " + listA.get(b).getStockQuantity()); // display total inventory.
System.out.printf("\n");
System.out.printf("Inventory value: $" + listA.get(b).getInvntval()); // display inventory value.
System.out.printf("\n\n");
System.out.printf("Restocking fee: $" + listA.get(b).getRestockfee()); // display restocking fee.
System.out.printf("\n\n");
}
System.out.printf("Total inventory value: $" + new dvdInventory().calculateInventory((ArrayList) listA));
System.out.printf("\n");
}
}
class dvdInventory // main method begins execution of Java application.
{
private String dvdname; // intialize dvd name.
private int stckquantity; // intialize number of items in stock.
private int itmnum; // intialize item number.
private double price; // intialize dvd price.
public double invntval; // intialize inventory value.
public String getName()
{
return this.dvdname;
}
public void setName(String dvdname)
{
this.dvdname = dvdname;
}
public int getStockQuantity()
{
return this.stckquantity;
}
public void setStockQuantity(int stckquantity)
{
this.stckquantity = stckquantity;
}
public int getItemNumber()
{
return this.itmnum;
}
public void setItemNumber(int i)
{
this.itmnum = i;
}
public double getPrice()
{
return this.price;
}
public void setPrice(double price)
{
this.price = price;
}
public double getInvntval()
{
return this.invntval;
}
public void setInvntval(double price, int units)
{
invntval = price * units;
}
public double calculateInventory (ArrayList a)
{
int i = a.size() - 1;
double intvalue = 0.0;
for (int b = 0; b <= i; b++)
{
intvalue = intvalue + ((dvdInventory) a.get(b)).getInvntval();
}
return intvalue;
}
}
class directorName extends dvdInventory //subclass of dvdinventory class.
{
private String dirName; // initialize director name.
private double restockfee; // initialize restocking fee.
public String getdirname()
{
return this.dirname;
}
public void setDirName(String dirname)
{
this.dirname = dirname;
}
public double getRestockfee()
{
return this.restockfee;
}
public void setRestockfee(double invntval)
{
restockfee = invntval * 0.05;
}
}
This post has been edited by Canucklehead: 29 March 2009 - 10:26 PM

New Topic/Question
Reply




MultiQuote





|