Have fun Jeff. I'm looking forward to seeing anything you write with it. :)
Thanks Shawn.. I've written a number guessing game so far. It's far from complete but it works well enough to let me understand the basics of Scala.
PHP Code:
*----------------------------------------------------------------
* PGM: GuessNumber.scala
* By: Jeff Farkas
* Guess a number between 1 and 100..
----------------------------------------------------------------*/
object GuessNumber {
def main(args: Array[String]){
//Set up the random number to guess.,
var rnd = new scala.util.Random
var range = 1 to 100
var rand_num = range(rnd.nextInt(range length))
println(rand_num)
//Set up count variable and get first guess..
var count = 1
var guess = readInt()
//Loop until the correct number is guessed....
while (guess != rand_num){
if (guess > rand_num){
println("Too High, try again.")
count += 1
print("Enter your guess: ")
guess = readInt()
} else{
println("Too Low, try again.")
count += 1
print("Enter your guess: ")
guess = readInt()
}
}
//End of Program and print out results...
println("Correct!!! And it took, " + count + " guesses.")
}
}