473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problems calling a method

hey wondering if anyone can help me with some work im doing
im trying to remove a record from a queue by using a method from a class.

class QueueNode
{
private String document ;
private String owner ;
private int size ;
private QueueNode next ;
private QueueNode previous ;

public QueueNode (String document , String owner , int size)
{
this.document = document ;
this.owner = owner ;
this.size = size ;
next = null ;
previous = null ;
}

public String getDocument()
{
return document ;
}

public String getOwner()
{
return owner ;
}

public int getSize()
{
return size ;
}

public QueueNode getNext()
{
return next ;
}

public QueueNode getPrevious()
{
return previous ;
}

public void setDocument(String document)
{
this.document = document ;
}

public void setOwner(String owner)
{
this.owner = owner ;
}

public void setSize(int size)
{
this.size = size;
}

public void setNext(QueueNode next)
{
this.next = next ;
}

public void setPrevious(QueueNode previous) //this is the part im having trouble with
{
this.previous = previous ;
}
}


class Queue
{
private QueueNode start ;
private QueueNode end ;

public Queue ()
{
start = new QueueNode("","",0) ;
start = null ;
end = new QueueNode("","",0) ;
end = null ;
}


public void add ( String document, String owner, int size )
{
if ( start == null )

{
start = new QueueNode(document,owner,size) ;
end = start ;

}

else
{
QueueNode temp = new QueueNode(document,owner,size) ;
temp.setNext (end) ;
end.setPrevious (temp) ;
end = temp ;
}
}

public boolean isEmpty ()
{
return ( start == null) ;
}

public QueueNode remove ()
{
QueueNode temp = new QueueNode("","",0) ;
if ( start == null )
return null ;

else if ( start.setPrevious == null)
{
temp = start ;
start = null ;
return temp ;
}
else
{
temp = start ;
start = start.setPrevious ;
return temp ;
}
}

public void displayAll ()
{

QueueNode temp = new QueueNode ("","",0) ;
temp = start ;
while ( temp ! = null )
{

System.out.println ( "Document: " + temp.getDocument() ) ;
System.out.println ( "Owner: " + temp.getOwner() ) ;
System.out.println ( "Size: " + temp.getSize() ) ;
temp = temp.setPrevious ;

}
}
}

and these are the errors im getting

Queue.java:47: cannot resolve symbol
symbol : variable setPrevious
location: class QueueNode
else if ( start.setPrevious == null)
^
Queue.java:56: cannot resolve symbol
symbol : variable setPrevious
location: class QueueNode
start = start.setPrevious ;
^
Queue.java:74: cannot resolve symbol
symbol : variable setPrevious
location: class QueueNode
temp = temp.setPrevious ;
^
3 errors

so im not calling setPrevious properly but whats wrong with it?

any help appreciated

thanks
Jan 10 '08 #1
7 1934
JosAH
11,448 Expert 8TB
Your method:

Expand|Select|Wrap|Line Numbers
  1. public void setPrevious(QueueNode previous) //this is the part im having trouble with
  2. {
  3.    this.previous = previous ;
  4. }
  5.  
... can only be called like this:

Expand|Select|Wrap|Line Numbers
  1. someObject.setPrevious(somePreviousNode);
  2.  
Simply put: you forgot the parentheses and the single parameter.

kind regards,

Jos
Jan 10 '08 #2
hey wondering if anyone can help me with some coursework im doing
im trying to remove a record from a queue by using a method from another class.

Expand|Select|Wrap|Line Numbers
  1.  class QueueNode
  2. {
  3. private String document ;
  4. private String owner ;
  5. private int size ;
  6. private QueueNode next ;
  7. private QueueNode previous ;
  8.  
  9. public QueueNode (String document , String owner , int size)
  10. {
  11. this.document = document ;
  12. this.owner = owner ;
  13. this.size = size ;
  14. next = null ;
  15. previous = null ;
  16. }
  17.  
  18. public String getDocument()
  19. {
  20. return document ;
  21. }
  22.  
  23. public String getOwner()
  24. {
  25. return owner ;
  26. }
  27.  
  28. public int getSize()
  29. {
  30. return size ;
  31. }
  32.  
  33. public QueueNode getNext()
  34. {
  35. return next ;
  36. }
  37.  
  38. public QueueNode getPrevious()
  39. {
  40. return previous ;
  41. }
  42.  
  43. public void setDocument(String document)
  44. {
  45. this.document = document ;
  46. }
  47.  
  48. public void setOwner(String owner)
  49. {
  50. this.owner = owner ;
  51. }
  52.  
  53. public void setSize(int size)
  54. {
  55. this.size = size;
  56. }
  57.  
  58. public void setNext(QueueNode next)
  59. {
  60. this.next = next ;
  61. }
  62.  
  63. public void setPrevious(QueueNode previous) 
  64. {
  65. this.previous = previous ;
  66. }
  67. }
  68.  
  69. -----------------------------------------------------------------------
  70. class Queue
  71. {
  72. private QueueNode start ;
  73. private QueueNode end ;
  74.  
  75. public Queue ()
  76. {
  77. start = new QueueNode("","",0) ;
  78. start = null ;
  79. end = new QueueNode("","",0) ;
  80. end = null ;
  81. }
  82.  
  83.  
  84. public void add ( String document, String owner, int size )
  85. {
  86. if ( start == null )
  87.  
  88. {
  89. start = new QueueNode(document,owner,size) ;
  90. end = start ;
  91.  
  92. }
  93.  
  94. else
  95. {
  96. QueueNode temp = new QueueNode(document,owner,size) ;
  97. temp.setNext (end) ;
  98. end.setPrevious (temp) ;
  99. end = temp ;
  100. }
  101. }
  102.  
  103. public boolean isEmpty ()
  104. {
  105. return ( start == null) ;
  106. }
  107.  
  108. public QueueNode remove ()
  109. {
  110. QueueNode temp = new QueueNode("","",0) ;
  111. if ( start == null )
  112. return null ;
  113.  
  114. else if ( start.setPrevious == null)
  115. {
  116. temp = start ;
  117. start = null ;
  118. return temp ;
  119. }
  120. else
  121. {
  122. temp = start ;
  123. start = start.setPrevious ;
  124. return temp ;
  125. }
  126. }
  127.  
  128. public void displayAll ()
  129. {
  130.  
  131. QueueNode temp = new QueueNode ("","",0) ;
  132. temp = start ;
  133. while ( temp ! = null )
  134. {
  135.  
  136. System.out.println ( "Document: " + temp.getDocument() ) ;
  137. System.out.println ( "Owner: " + temp.getOwner() ) ;
  138. System.out.println ( "Size: " + temp.getSize() ) ;
  139. temp = temp.setPrevious ;
  140.  
  141. }
  142. }
  143. }
  144.  
and these are the errors im getting

Expand|Select|Wrap|Line Numbers
  1.  Queue.java:47: cannot resolve symbol
  2. symbol : variable setPrevious
  3. location: class QueueNode
  4. else if ( start.setPrevious == null)
  5. ^
  6. Queue.java:56: cannot resolve symbol
  7. symbol : variable setPrevious
  8. location: class QueueNode
  9. start = start.setPrevious ;
  10. ^
  11. Queue.java:74: cannot resolve symbol
  12. symbol : variable setPrevious
  13. location: class QueueNode
  14. temp = temp.setPrevious ;
  15. ^
  16. 3 errors
  17.  
what do i have to change?
i did get a reply but it didnt make much sense to me (sorry jos)

thanks
Jan 10 '08 #3
r035198x
13,262 8TB
See how you wrote line 98 above. That's how you should call a method.
Jan 11 '08 #4
Laharl
849 Expert 512MB
In addition to not actually calling your functions, when setting something equal to the previous entry, you would need to use get, rather than set. This is found in all three errors.
Jan 11 '08 #5
JosAH
11,448 Expert 8TB
What is wrong with my answer in your other identical thread?
Don't double post and stick to one thread for one problem.

kind regards,

Jos
Jan 11 '08 #6
r035198x
13,262 8TB
What is wrong with my answer in your other identical thread?
Don't double post and stick to one thread for one problem.

kind regards,

Jos
Argh.
<shakes head>
Jan 11 '08 #7
RedSon
5,000 Expert 4TB
jomcfall97,

You are skating on thin ice. Double posting, not using [code] tags, and generally being dense are among your infractions. If Jos's post did not make sense to you then politely ask him to explain.

You need to read the posting guidelines, because the next problem might result in a 5-7 day ban on your account.

-MODERATOR
Jan 14 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Gary | last post by:
sorry for not cross-posting originally (originally posted in the components subgroup) I seem to have run into two documented bugs whose workarounds are incompatible. What I have is an OCX...
15
by: Mark Gillespie | last post by:
I have a class that launches a process (amongst other things). I keep track of the process handle, and just prior to the obejct being destroyed by the garbage collector, I want to kill that...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
1
by: Tim::.. | last post by:
Hi, Can someone please tell me why this doesn't work! I keep getting an error in the build saying! "Argument not specified for parameter 'e' of Public Sub PopulateDropdown..." I would be...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
5
by: zq | last post by:
Hi! I am have a COM object which occupies more and more memory everytime it's used. The "VM size" counter (private bytes) of the process that uses the COM object keeps on growing when...
1
by: Thomas Due | last post by:
Hi, I manage an rather old application in which we have some fairly complex (ugly) Delphi code. This is Delphi 6 we're talking about. Among all this Delphi code there is method for formating a...
5
by: =?Utf-8?B?Sm9obiBT?= | last post by:
I am trying to find out if there is a way to tell if there is already a filesystemwatcher (created by a webservice) monitoring a folder. I have a webservice that creates a filesystemwatcher,...
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
0
by: =?Utf-8?B?RGF2ZSBIZXJybWFubg==?= | last post by:
I have a web service (.NET 2.0) that defines a method with two input parameters. Both of these input parameters are defined as "int". This web service is running on a 32-bit machine. There is a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.