To have your philosopher perform one of their functions, you will type something like this:
As you can see, you start by typing "philo", type a ".", then use the name of the function you'd like to perform. In this case, we're asking our philosopher to pick up his right fork.
Functions always have a pair of parentheses after their names when they're being asked to do things, and these parentheses can include special parameters or arguments. Those are fancy words for input. For example, the previous function can be used to pick up the "Right" or "Left" fork, depending on which is typed in its parentheses. Don't forget those quotation marks!
Some functions are like asking questions of the object (or philosopher), and can be used in conditional (if) statements! For example, you could write:
In this example, the function putDownFork() is wrapped up in an "if" statement. Without any functions, an if statement looks like this:
It looks pretty lonely like this, but you can plainly see that the special if function has both parentheses after it, which takes a true or false statement. Then, depending on whether the statement was true or false, the program will execute the code between the curly braces.
An if statement can take all types of true/false statements. Sometimes you want to compare two numbers! For example, this statement will always equal true or false.
philo.lifeRemaining() < 50
Here we've made a statement that checks if the philosopher's life is less than 50. You might recognize the less-than symbol (<) from math class, and it's no different here! In fact, there are several such "operators" we can use to make true or false statements:
|>||Greater Than Than|
|<=||Less Than or Equal To|
|>=||Greater Than or Equal To|
|!==||Not Equal To|
Also, an exclaimation mark ("!") before a true/false statement makes it the opposite. For example:
Translates to "If the philosopher is not eating, pick up the left fork."
Well, that should be enough to get started! Below I've got the API, which is an Application Programmer's Interface. It's like a programmer's dictionary. It tells you all the functions you need to know to use this particular program.