Some questions people had in class #12

 

What kinds of tests are acceptable in if statements? Is there a limit to what you can put in the brackets of an if statement? (same question if this means the ()’s)

 

 

Anything that results in a boolean (true/false) result. We can test for greater than, less than, equal to, not equal to, greater than or equal to, less than or equal to. We can logically combine tests with AND (&&) or OR (||). We can reverse a test with NOT (!). We can combine multiple tests with all sorts of combinations of ANDs and ORs. In short, we can make the test as complicated as we need it to be to accomplish our task.

 

Is there a limit to what you can put in the brackets of an if statement? (if this means the {}’s instead of the ()’s)

 

Any combination of legal statements. As complex as we need it.

 

How do you use a conditional statement? Just by using if __ < __ ? How to complete a conditional statement?

 

Remember the ()’s around the test. And if the actions are more than one statement, make sure to enclose with {}’s. Also, if-else statements are probably more common than just plain if’s. I will do a class where we solve a problem using conditionals (if’s).

 

How often are conditionals needed in a program?

 

Almost all programs need them. You probably will not write another program this semester that doesn’t have at least one in it.

 

How do we add color in a program, and pictures?

 

We need to create a GUI interface. It is somewhat hairy, we won’t talk about it this semester. However, you can find some info about this in the optional sections in the ends of several different chapters in the book.

 

Do you believe that static methods are “workarounds”?

 

Yes, but probably necessary ones. When using static methods, we completely avoid using objects, but some tasks don’t really need objects.

 

I still don’t fully understand static methods.

 

I’m not sure how to address this, because I don’t know what you don’t understand. Ask me.

 

What are all the different uses of Math.abs?

 

Computer programs can be written for an infinite number of tasks, limited mostly just by one’s imagination. Math.abs, will come into play more with science and math tasks, but it can also be useful with graphics, games, etc, etc