• Post Reply Bookmark Topic Watch Topic
  • New Topic

signal generator part 2

 
Stephen Carter
Greenhorn
Posts: 22
Chrome Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Continued from this page (http://www.coderanch.com/t/656287/GUI/java/signal-generator)
I have cleaned up my code and now trying to call another class, which the program will do, but I get this error:

SIGGEN_msc.java:58: error: method generate in class oscillate cannot be applied to given types;
if (a.equals("Sine")) { o.generate(fre,len,amp,"Sine"); textArea.setText("Sine\n"); }
^
required: int,int,int
found: int,int,int,String
reason: actual and formal argument lists differ in length

This error continues on lines 59, 60, 61, and 62.
From what I gather, it is telling me that it is not finding the String type, but String is called as an ActionPerformed event.
I will include my code, and a snippet of the oscillate code.





Thank you.
 
Henry Wong
author
Sheriff
Posts: 22518
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephen Carter wrote:I get this error:
SIGGEN_msc.java:58: error: method generate in class oscillate cannot be applied to given types;
if (a.equals("Sine")) { o.generate(fre,len,amp,"Sine"); textArea.setText("Sine\n"); }
^
required: int,int,int
found: int,int,int,String
reason: actual and formal argument lists differ in length

From what I gather, it is telling me that it is not finding the String type, but String is called as an ActionPerformed event.


Nope. It is telling you that it can't find a generate() method of the occillate class that takes four parameters -- specifically an int, int, int, and String. The closest match that it could find is the method that takes three ints.

Henry
 
Fred Kleinschmidt
Bartender
Posts: 451
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only code that is relevant here is all of the code for the oscillate class (Note: By convention, class names should always begin with a capital letter). The error message is quite explicit - you haven't defined a method called "generate" that takes four arguments (int,int,int,String) but you are trying to call such a method.
 
Stephen Carter
Greenhorn
Posts: 22
Chrome Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I have to include string in the oscillate class? (the snippet I provided).
 
Fred Kleinschmidt
Bartender
Posts: 451
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you have to define a function called "generate" IN THE OSCILLATE CLASS, THAT TQAKES FOUR ARGUMENTS:
`public void generate (int firstInt, int secondInt, int thirdInt, String someString ) {
// do something here using the above arguments
}`
 
Stephen Carter
Greenhorn
Posts: 22
Chrome Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fred Kleinschmidt wrote:No, you have to define a function called "generate" IN THE OSCILLATE CLASS, THAT TQAKES FOUR ARGUMENTS:
`public void generate (int firstInt, int secondInt, int thirdInt, String someString ) {
// do something here using the above arguments
}`


Thank you for your reply. I added that to oscillate class and when I try to compile siggen i get

SIGGEN_msc.java:58: error: unreported exception LineUnavailableException; must be caught or declared to be thrown
if (w.equals("Sine")) { o.generate(fre,len,amp,"Sine"); textArea.setText("Sine\n"); }


Nothing has been changed in siggen.java
^



EDIT

Fixed it and it works. Thank you all.
 
Fred Kleinschmidt
Bartender
Posts: 451
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This method is infinite recursion - calling it will create a stack overflow exception.
 
Stephen Carter
Greenhorn
Posts: 22
Chrome Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fred Kleinschmidt wrote:

This method is infinite recursion - calling it will create a stack overflow exception.


It hasn't yet.

I am going to close this thread. Thank you for your replies.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!