简体   繁体   中英

How can I have my script run another script when a condition has been met? (Java)

I have a script that runs a Black Jack game in Java and currently it is set up in such way that if you lose (run out of money), a message will appear saying that you lost and are out of money.

What I would like to do is to have it run a second script, when you run out of money. I've tried figuring it out but i can't seem to get it.

if (money == 0)
{
    System.out.println("Looks like you've are out of money!");
    break;
}

I think you need a method . You can declare a method like this:

private static void myMethod () {

}

You can replace the word myMethod with the name of your second script. You can run (call) this method by

myMethod ();

And in the curly braces you can start writing your second script.

To Learn more about methods, read https://docs.oracle.com/javase/tutorial/java/javaOO/methods.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM