9 Replies - 7260 Views - Last Post: 01 April 2009 - 08:51 PM Rate Topic: -----

#1 Canucklehead  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-March 09

Calling subclass items from superclass.

Post icon  Posted 29 March 2009 - 10:24 PM

Hello, I am unable to get this to complie and I think it is because the superclass can not reference the sub-class methods. I have tried the posts linked, but I am at a dead end. Since I am stuck I have tried various, some of which you will see commented out (some of which are out fo shear desperation). I added the subclass directorName and have tried to get it to add a unique dvd attribute and include the surcharge to the restocking fee. My instructor stated that I should create a new instance of class directorName which doesnt' make sense to me:

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(B).getDirName()); // display directors name.
^
dvd.java:69: cannot find symbol
symbol : method getRestockfee()
location: class dvdInventory
System.out.printf("Restocking fee: $" + listA.get(B).getRestockfee()); // display restocking f
^
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


Is This A Good Question/Topic? 0
  • +

Replies To: Calling subclass items from superclass.

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4361
  • View blog
  • Posts: 12,180
  • Joined: 18-April 07

Re: Calling subclass items from superclass.

Posted 29 March 2009 - 10:33 PM

You are exactly right with your assessment of what is going wrong. You created "dvdObject" to be of the type "dvdInventory". getDirName and setDirName are methods of a "directorName" class which is a type of dvdInventory.

So to solve this you need to make dvdObject a type of directorName instance. Thus you can access those specific methods plus all the methods in common to a dvdInventory (since directoryName is a type of dvdInventory...according to your class hierarchy here).

You are trying to create a super class object and then access a child class methods. This won't work. Now if you make the instance an instance of the child class, then it will have the methods you want plus it will inherit all its parent class' methods.

:)
Was This Post Helpful? 1
  • +
  • -

#3 Canucklehead  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-March 09

Re: Calling subclass items from superclass.

Posted 29 March 2009 - 10:54 PM

Thank you for your quick reply.

I have researched this to death (I think). Does this page point me in the right direction?

http://java.sun.com/.../classvars.html

If so, I'm completely lost since it doesnt' make sense to me what I have to do next.

I added dvdobject directorName but still recieve the same errors. Is that too simplistic?


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.
		directorName dvdObject = new directorName(); // 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");
}

}

Was This Post Helpful? 0
  • +
  • -

#4 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Calling subclass items from superclass.

Posted 29 March 2009 - 11:01 PM

I am sorry but this is irritaingggg.. If your not going to format it.. use println
		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");



Goodluck fixing the problem!

This post has been edited by Fuzzyness: 29 March 2009 - 11:01 PM

Was This Post Helpful? 0
  • +
  • -

#5 Canucklehead  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-March 09

Re: Calling subclass items from superclass.

Posted 29 March 2009 - 11:06 PM

Us noobs do things like that, but you already know that. Of course you are right. Right now though, I need to get it working. Cheers.
Was This Post Helpful? 0
  • +
  • -

#6 Canucklehead  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-March 09

Re: Calling subclass items from superclass.

Posted 30 March 2009 - 08:02 PM

Hello, I thought I had this beat, but I am still getting errors. What am I not doing right? Thank you in advance.

dvd.java:52: cannot find symbol
symbol : method sort(java.util.List<directorName>)
location: class java.util.Collections
Collections.sort(listA);
^
dvd.java:60: cannot find symbol
symbol : method getDirName()
location: class directorName
System.out.printf("Directors name: " + listA.get(B).getDirName()); // display directors name.
^
dvd.java:147: cannot find symbol
symbol : variable dirname
location: class directorName
return this.dirname;
^
dvd.java:151: cannot find symbol
symbol : variable dirname
location: class directorName
this.dirname = dirname;
^
4 errors

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.
		directorName dvdObject = new directorName(); // 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);
		}
	}
	//Collections.sort(listA, new Comparator);
	Collections.sort(listA);
	int a = listA.size() - 1;
	int b;
	for (b = 0; b <= a; b++)
	{
		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.	 
	//directorName dvdInventoryObject = new directorName(); // set object.
	
	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;
	}
}

Was This Post Helpful? 0
  • +
  • -

#7 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4361
  • View blog
  • Posts: 12,180
  • Joined: 18-April 07

Re: Calling subclass items from superclass.

Posted 30 March 2009 - 08:31 PM

Please do not use the thanks link just to comment about your code to me, if I can help I will. Just so happens I have described what problems you are having and have a FULLY WORKING version of it below...

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.
        directorName dvdObject = new directorName(); // 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);
        }
    }
    //Collections.sort(listA, new Comparator);
    Collections.sort(listA);
    int a = listA.size() - 1;
    int b;
    for (b = 0; b <= a; b++)
    {
        listA.get(B );
        System.out.printf("DVD name: " + listA.get(B ).getName()); // display DVD name.
        System.out.printf("\n");

        // getdirename is all lowercase here!
        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.    
    //directorName dvdInventoryObject = new directorName(); // set object.
   
    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;
    }
}

// We have to implement the comparable interface for our object so that Collections.sort above knows HOW to sort
// this object compared to other directorName objects.
class directorName extends dvdInventory implements Comparable<directorName>//subclass of dvdinventory class.
{
    private String dirName; // initialize director name.
    private double restockfee; // initialize restocking fee.
   
	// Notice the case on this method, all LOWERCASE!!!
    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;
    }
	
    // We need to implement a compareTo method for this class to meet the interface obligations
    // the sort method of collections needs to know HOW to sort this object. Here we are comparing directors names.
    public int compareTo(directorName direct2) {
        return this.dirName.compareTo(direct2.getdirname());
    }
}



Because you are attempting to sort an array list of CUSTOM objects here, you have to tell the sort method how you can sort these items. What does it mean to sort directorName objects? To do this we have to implement an interface called Comparable and then add its one method called compareTo to show it how they compare. In this method you teach Java how to compare your objects.

In the working version above we tell Java to compare two directorName objects by comparing the director's name.

It sorts based on comparing two objects in the list and determines which is greater or if they are equal. So look over this method real quick and learn what I am doing here.

Next, keep in mind that Java is CASE SENSITIVE! This means getDirName, getdirname and getdirName() are all different. Your other errors were related to this problem.

Have a good day.

"At DIC we be director comparing code ninjas... Spielberg beats Clint Eastwood any day of the week" :snap:

This post has been edited by Martyr2: 30 March 2009 - 08:33 PM

Was This Post Helpful? 1
  • +
  • -

#8 Canucklehead  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-March 09

Re: Calling subclass items from superclass.

Posted 30 March 2009 - 09:05 PM

Hello, Thank you for going through that. I need to sort by the DVD name, but I will try to use the example you have provided that sorts the director's name. Sorry about not being specific enough, but that will help a lot and I will learn something out of adapting it. Much appreciated. Sorry about the Thank you note, it was not my intent to askyou for help through it, just say thank you for helping.

I will try adapting what you provided after I write a paper for another class I have tonight and see if I can get it to work.

Cheers, and thanks again.
Was This Post Helpful? 0
  • +
  • -

#9 Canucklehead  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-March 09

Re: Calling subclass items from superclass.

Posted 01 April 2009 - 08:21 PM

I just wanted to thank everyoen that helped. I think I have it now, but I keep getting this error:

dvd.java:75: class, interface, or enum expected
import java.util.ArrayList;
^
1 error

Here is line 75 prior to a class: import java.util.ArrayList;

I have searched through the sun tutorials and forums and I have checked my curly braces and made sure (I think) there is nothing strange going on. I am using Eclipse so it is fairly easy to match the braces up. I read that textpad can insert an unsual character at the end of the file so I made sure there was no white space there or between classes. Same error. Before I post my codeout of desperation is there anything else I should consider? I don't want to waste someone's time by having them tell me I'm missing a curly brace.

Thank you.
Was This Post Helpful? 0
  • +
  • -

#10 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 521
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: Calling subclass items from superclass.

Posted 01 April 2009 - 08:51 PM

You have to import at the top of the file...no matter what.

You can't have those statements in between classes. All import(s) must be before any class declaration.

This post has been edited by Locke: 01 April 2009 - 08:52 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1