• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Constructor with super(value) as first line - 'value' variable won't change!?

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys. But of a tricky one to explain this!
I have a class called SingleDelayEffect, which has a constructor: This gets the values from a class called SingleDelay. However SingleDelayEffect extends a class called AudioEffect. You can see here that i have used super(value) to add the value of 'fowardMemSize' to the contructor of AudioEffect. This is fine, but what if the forwardMemSize changes? Ordinarily (for a variable like 'feedback')i can juse ues a method like: to get the value of feedback from the SingleDelay class if this value changes. But because the value of forwardMemSize is calculated in SingleDelay, and passed over, it won't change. In the SingleDelay class, i'm making a new object each time:
I know the super(); call has to be the first line of the constructor so what do i do it this value varies
I know i made a pigs ear of explaing this so if any more info is needed i can reply straight away
Thank you!
[ April 06, 2004: Message edited by: Eddie Shakarchi ]
 
Eddie Shakarchi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I should add that in fact i want super(forwardMemSize) to actually be whatever is set here:
 
Eddie Shakarchi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no one?
i think it's impossible, right?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The short answer (and I'm not sure why I need to explain this again, as this seems to me to be the identical question I've already answered) is to give the appropriate class (here, it's AudioEffect) a setXXX method, which can then be called from or on instances of SingleDelayEffect (the method will be inherited by this class.)
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are violating one of The Rules(TM).
Calling an overridable method on a 'this' (implied or not) reference from a constructor.
An overrideable method is defined as one that is non-private, non-static, non-final, a member of a non-final class with at least one non-private constructor.
 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic