Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error Message "cannot find symbol"

 
Katie Makin
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, when I try to compille my code, an error message pops up that says "Cannot find symbol" - can someone PLEASE tell me what I am doing wrong? Here is the entire code:


/**
* This class performs all of the printing for the DiskCase class.
*
* @author Kathryn Makin
* @version 2009 4 June
*/
public class ListPrinter
{
private String printOwner;
private String printDiskLocation;
private String printDateStarted;
private int printDisksCaseCanHold;
private int printNumberOfDisksInCase;


/**
* Constructor for objects of class ListPrinter
*/

public ListPrinter(String owner, String DiskLocation, String date, int disks, int numberOfDisks)

{
owner = printOwner;
DiskLocation = printDiskLocation;
date = printDateStarted;
disks = printDisksCaseCanHold;
numberOfDisks = printNumberOfDisksInCase;
}


/**
* Return the owner name of DiskCase.
*/

public String OwnerName( String owner)
{
return printOwner;
}

/**
* Return the location of diskCase.
*/

public String DiskLocation( String DiskLocation)
{
return printDiskLocation;
}

/**
* return the date DiskCase was started.
*/

public String DateStarted(int date)
{
return printDateStarted;
}

/**
* Return the number of disks DiskCase can hold.
*/

public int AmountOfDisksCaseCanHold(int disks)
{
return printDisksCaseCanHold;
}

/**
* Return the number of disks in DiskCase right now.
*/

public int NumberOfDisksInDiskCase(int numberOfDisks)
{
return printNumberOfDisksInCase;
}

public void addDisk(Disk newDisk)
{
if(disks.location() == printDiskLocation) {
System.out.println("Location of this Disk,");
}


else {
disks.add(newDisk);
disksInCase++;
}
}


/**
*Print the above information for the DiskCase class.
*/

public void printList()
{
System.out.println("OwnerName: " + printOwner);
System.out.println("DiskLocation: " + printDiskLocation);
System.out.println("DateStarted: " + printDateStarted);
System.out.println("DisksCaseCanHold: " + printDisksCaseCanHold);
System.out.println("NumberOfDisksInCase: " + printNumberOfDisksInCase);
System.out.println("");

Iterator i = disks.iterator();
while(i.hasNext()) {
Disk disk = (Disk)i.next();
disk.print();

System.out.println("Number of disks: " + numberOfDisks());
}
}
}


The error message highlites my if/else statements.

THANK YOU FOR YOUR HLP!!
 
W. Joe Smith
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Katie Marie wrote:Hi, when I try to compille my code, an error message pops up that says "Cannot find symbol" - can someone PLEASE tell me what I am doing wrong?

public void addDisk(Disk newDisk)
{
if(disks.location() == printDiskLocation) {
System.out.println("Location of this Disk,");
}


else {
disks.add(newDisk);
disksInCase++;


Can you give us a little more information? What is the full error message? What symbol can it not find? Can you post more of your source code?
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And please Use Code Tags
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing to do with your question, but your constructor is totally wrong


You are assigning the values of your class variables to the constructor parameter variables.
All those assignments should be the other way round.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
W. Joe Smith
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure, but I think your problem is here:

if(disks.location() == printDiskLocation)

I'm guessing the program is telling you it cannot find symbol "disks". From what I can see, the only place you declare "disks" is here:



I don't see anywhere that disks is declared outside that constructor, and I believe that means it only exists inside the constructor. And since you are calling a method, I'm assuming it should be an object of some kind.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic