/*  Exploring Languages with Interpreters and Functional Programming
    Copyright (C) 2019, H. Conrad Cunningham
    Modular Counting Program in Scala--Using object

1234567890123456789012345678901234567890123456789012345678901234567890

2019-01-24: Adapted from CountingMod.py and CountingProc.scala
2019-01-28: Comment/formatting update
* 
*/

object CountingMod {

    var count =  0   // public, using type inference 
    var maxc  = 10   // declaration & setter/getter better practices 

    private def has_more(count: Int, maxc: Int): Boolean = 
        count <= maxc 

    private def incr {
        count = count + 1
    }
    
    def counter {
        while (has_more(count,maxc)) {
            println(count.toString)
            incr
        }
    }
}

object CountingModTest {

  def main(args: Array[String]) {
        CountingMod.counter
        println("[1..20]")
        CountingMod.count =  1
        CountingMod.maxc  = 20
        CountingMod.counter
    }

}


