summary on resolution, thought dealing scala problem turns out stopwatch , scala logging have private constructors, , not calling proper public methods instantiate them. gzm0's answer below points out.
trying use guava stopwatch , scala logging, no matter whether create new stopwatch()
or new logger()
in main or in instantiated class error gradle run
:
constructor logger in class logger cannot accessed in class redblacktree4150 var loggerinst = new logger() constructor stopwatch in class stopwatch cannot accessed in class redblacktree4150 var stopwatchinst = new stopwatch()
if duplicate of this or this question don't know enough realize it. looked @ this question doesn't have accepted answer, , tried (just fun) take parens off constructor calls no avail.
writing first gradle/scala project analysis of algorithms assignment. think if in java asking static vs. non-static, not sure if that's type of issue dealing with. scala not part of assignment not using homework tag.
here's how calling them , first part of program, the full .scala file , build.gradle on github
import com.google.common.base.stopwatch import com.typesafe.scalalogging.slf4j.logger import scala.collection.immutable.treemap import java.util.concurrent.timeunit object main extends app { // var rbtree = new redblacktree4150(logger, stopwatch) var rbtree = new redblacktree4150() } // class redblacktree4150 (var loggerinst: logger, var stopwatchinst: stopwatch) { class redblacktree4150() { var loggerinst = new logger() var stopwatchinst = new stopwatch()
as can see have tried simplifying making 1 object, , instantiating logger , stopwatch in main , passing them class (bad idea know) none of works. simple scala thing missing here? thanks.
otherwise believe have dependencies in project properly, , same error on command line.
i have 1 more error i posted separate question here, in case it's relevant, error is:
/home/jim/workspace/scala/redblacktree4150/src/main/scala/main.scala:36: value map not member of double timingsmap = (i <- powerslist; j <- runtest(i)) yield -> j
the constructors of both stopwatch
, logger
private. need use factory methods instantiate them.
in case of stopwatch
, use createunstarted()
method:
val stopwatch = stopwatch.createunstarted()
in case of logger
, must use apply
method. however, requires underlying slf4j logger. can create 1 through slf4j's loggerfactory
:
import org.slf4j.loggerfactory val logger = logger(loggerfactory.getlogger(getclass))
Comments
Post a Comment