473,698 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems calling a method

2 New Member
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(Str ing document)
{
this.document = document ;
}

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

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

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

public void setPrevious(Que ueNode 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(docum ent,owner,size) ;
end = start ;

}

else
{
QueueNode temp = new QueueNode(docum ent,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.setPrevio us == null)
{
temp = start ;
start = null ;
return temp ;
}
else
{
temp = start ;
start = start.setPrevio us ;
return temp ;
}
}

public void displayAll ()
{

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

System.out.prin tln ( "Document: " + temp.getDocumen t() ) ;
System.out.prin tln ( "Owner: " + temp.getOwner() ) ;
System.out.prin tln ( "Size: " + temp.getSize() ) ;
temp = temp.setPreviou s ;

}
}
}

and these are the errors im getting

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

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

any help appreciated

thanks
Jan 10 '08 #1
7 1949
JosAH
11,448 Recognized Expert MVP
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
jomcfall97
2 New Member
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 MVP
See how you wrote line 98 above. That's how you should call a method.
Jan 11 '08 #4
Laharl
849 Recognized Expert Contributor
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 Recognized Expert MVP
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 MVP
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 Recognized Expert Expert
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
3577
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 written in VB 6 that has a few classes in it. Many of the methods of the OCX are used by ASP, and so far have worked fine. I recently added a COM object reference to the DLL which consists of an SMTP client dll that is wrapped up in dual interface...
15
2773
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 process. Basically, if some exits my application, I don't want any stray background applications running created by instances of my class. I tried calling the kill() method on the process handle in the class's destructor, but the handle must have...
5
3425
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 5), but fails on IIS 6 running on a Win2003 server. The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide some common functionality. The Page_Load handler the failing webpage starts out like this: ...
1
1061
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 really grateful for any help! The dropdownlist is in the footer of a datagrid and I would like to use it to add and edit records. Thanks for any help!
4
3527
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 objective in utilizing this new deployment method is to reduce the maintenance overhead as well as making it easier for my users to setup and run the application initially. I have VS 2002, Windows XP, Access XP(2000 format). He is my problem....
5
2717
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 instantiating and using the object frequently. I tried following strategies for using the object: 1. instantiate the object when the app starts, use it frequently (inside an
1
8080
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 print layout for slip printers. Pass a few parameters to this method and it returns a Delphi string which contains the entire slip, ready for sending to the slip printer. Now, we're slowly migrating to .NET and am in need of printing this slip...
5
5597
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, monitors a folder and then returns the contents of the new/changed files. However, if the client app loses connection to the webservice without closing the filewatcher, and then reconnects (and thus creates a new watcher), I believe I end up with...
14
3782
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 more why C++/CLI would be better to PInvoke than doing the PInvoke in C#? Because, usually in C# as you already know we use DLLImport and extern
0
1496
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 client that is calling this web service method. The client is running on a 64-bit machine (written in VB). It declares the two input parameters to be LONGs (64-bit) and is passing these LONG values into the web service that defines these as int....
0
8680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.