我正在尝试运行此程序,但它告诉我没有找到r.你怎么称呼这个方法,因为它在课堂上?(我假设错误是因为这个)
package pack
class Sud(val grid: List[List[Int]]) {
def r(r: Int): List[Int] =
//code
}
object Sud
{
def main(args: Array[String])
{
val puzzle=new Sudoku(List(
List(0, 0, 9, 0, 0, 7, 5, 0, 0),
//rest of Sudoku puzzle created by repeating the above statement
println(r(0)) //ERROR given here
}
}
Run Code Online (Sandbox Code Playgroud)
如评论中所述,在您的代码中r是一个类方法.因此,您需要实例化您的类Sud才能调用该方法.
val inst: Sud = new Sud(puzzle)
println(inst.r(0))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9472 次 |
| 最近记录: |