title: How to access methods in a class nested within an abstract class?
body: <p>UPDATE[SOLVED]: needed to put the gates outside of nested <code>Wire</code> class (thanks Dima).</p>
  
  <p>EDIT: I'm not sure why I was downvoted for this question. This is a legit question because I'm taking the online coursera course in Reactive Programming by Martin Odersky, and if you go and look at lecture 3.6 "discrete event simulation implementation and test" yourself, you will see that Martin implemented the code exactly as I did and he did not get these errors. This was not an assignment, all code was presented and I simply copied it from the slides. You can see below screenshots from the actual video showing that the gates are written <em>inside</em> of Wire class.</p>
  
  <p><a href="https://i.stack.imgur.com/4YaQ9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4YaQ9.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/X7OXU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X7OXU.png" alt="enter image description here"></a></p>
  
  <p>I have an abstract class <code>Circuits</code> (in file Circuits.scala) which extends an abstract class <code>Gates</code>. Within <code>Gates</code> is defined a class <code>Wire</code> (both Gates and Wire are in file Gates.scala). And inside of this class <code>Wire</code> is defined several functions one of which is <code>orGate</code>. When I try to access <code>orGate</code> and other functions inside <code>Wire</code>, the IDE complains with <code>symbol not found</code>. What special thing do I need to do so that <code>orGate</code> etc. are visible from <code>Circuits</code>? Code snippets to illustrate my issue follows.</p>
  
  <p>file Circuits.scala:</p>
  
  <pre><code>package week3      
  abstract class Circuits extends Gates {
  
        def halfAdder(a: Wire, b: Wire, s: Wire, c: Wire) {
          val d, e = new Wire
          orGate(a, b, d)      // &lt;--- symbol not found: orGate
          andGate(a, b, c)     // &lt;---- symbol not found: andGate 
          inverter(c, e)       // &lt;--- etc.
          andGate(d, e, s)
        }
  
        def fullAdder(a: Wire, b: Wire, cin: Wire, sum: Wire, cout: Wire) {
          val s, c1, c2 = new Wire
          halfAdder(a, cin, s, c1)
          halfAdder(b, s, sum, c2)
          orGate(c1, c2, cout)
        }
  
      }
  </code></pre>
  
  <p>file: Gates.scala:</p>
  
  <pre><code>package week3
  
  
  abstract class Gates extends Simulation {
  
    def InverterDelay: Int
    def AndGateDelay: Int
    def OrGateDelay: Int
  
    class Wire {
  
      private var sigVal = false
      private var actions: List[Action] = List()
  
      def getSignal: Boolean = sigVal
      def setSignal(s: Boolean): Unit = {
        if (s != sigVal) {
          sigVal = s
          actions foreach (_())
        }
      }
      def addAction(a: Action): Unit = {
        actions = a::actions
        a()
      }
  
      def inverter(input: Wire, output: Wire): Unit = {
        def invertAction(): Unit = {
          val inputSig = input.getSignal
          afterDelay(InverterDelay) { output setSignal !inputSig}
        }
        input addAction invertAction
      }
  
  
      def andGate(in1: Wire, in2: Wire, output: Wire): Unit = {
        def andAction(): Unit = {
          val in1Sig = in1.getSignal
          val in2Sig = in2.getSignal
          afterDelay(AndGateDelay) {output setSignal (in1Sig &amp; in2Sig)}
        }
  
        in1 addAction andAction
        in2 addAction andAction
      }
  
  
      def orGate(in1: Wire, in2: Wire, output: Wire): Unit = {
        def orAction(): Unit = {
          val in1Sig = in1.getSignal
          val in2Sig = in2.getSignal
          afterDelay(OrGateDelay) {output setSignal (in1Sig | in2Sig)}
        }
  
        in1 addAction orAction
        in2 addAction orAction
      }
  
      def probe(name: String, wire: Wire): Unit = {
        def probeAction(): Unit = {
          println(name, currentTime, wire.getSignal)
        }
        wire addAction probeAction
      }
  
  
    }
  }
  </code></pre>