So I have this variable, currentPartNumber, which starts off being equal to 0. What I want to happen is in my function, if the variable is equal to zero, it is changed to 1 and the text is printed out. Same thing for my second function - if the variable was changed to 1 in my first function and is equal to one, I want the variable to change to 2 an print out the text.
The problem is: How do I get the variable to change with each function call like I want?
var currentPartNumber = 0
def roomOne():Unit = {
if (currentPartNumber < 1) {
var currentPartNumber = 1
println("You now have parts 1 of 4.")
} else {
println("This part cannot be collected yet.")
{
}
def roomTwo():Unit = {
if (currentPartNumber = 1) {
var currentPartNumber = 2
println("You now have parts 2 of 4.")
} else {
println("This part cannot be collected yet.")
{
}