Stage 0: Operators + Java Fundamentals#20
Conversation
ArchdukeTim
left a comment
There was a problem hiding this comment.
There are already many free online courses that teach an introduction to java and its syntax. Would it be better to just recommend one of them as a precursor, rather than trying to reinvent the wheel?
| Data types refer to the type of value that our variable has. It helps tell our program more information about our variables such as what type of information it holds and how it can be used. | ||
| Data types can include numbers, characters or a string of words. Some examples of data types that are commonly used in FRC programming are: | ||
| * Int: integers or numbers that are positive or negative. Int only allows numbers without decimals. Example: 12 | ||
| * Double: Double: numbers that are positive or negative. Unlike int, double allows numbers with or without decimals. Example: 34.1 |
There was a problem hiding this comment.
| * Double: Double: numbers that are positive or negative. Unlike int, double allows numbers with or without decimals. Example: 34.1 | |
| * Double: numbers that are positive or negative. Unlike int, double allows numbers with or without decimals. Example: 34.1 |
| ## Syntax | ||
| As you start programming, you might make a mistake or make a typo. When that happens, your code will have a red line under it. This is because Java has rules called syntax. Syntax is a set of rules that have to be followed so that the computer can understand and run your code. It’s important to pay attention to the syntax! |
There was a problem hiding this comment.
Syntax errors are common, but not the only reason that you might get a compiler error. For example, using a misspelled variable name is valid syntax, but still an error.
| The name of your variable can be whatever you want. However, it should be easy to read and make sense to others who may be reading your code. | ||
| There are also some rules with variable names. The name of the variable can not include spaces. Instead you can write variables with camel case (frontLeftDrive) and snake case (front_Left_Drive). | ||
| Variable names can not start with a number. However, they can have a number at the end of the name. |
There was a problem hiding this comment.
can be whatever you want...rules with variable names
It would be better to just state what the rules and maybe conventions are
they can have a number at the end of the name
They can have a number anywhere except the start
Co-authored-by: Tim Winters <twinters007@gmail.com>
…oftware.org into Stage-0-Operators
ea813ca to
f514f00
Compare
|
🌐 Preview URL: https://pr-20.frcsoftware.pages.dev |
roboteer5291
left a comment
There was a problem hiding this comment.
Java fundamentals looks good.
I didn't call out the instances of this, but in line with what's standard convention and used in the rest of the course, variables used in the operators section shouldn't be capitalized.
Also, maybe we should include all references to variables names and operators in single tick code blocks? If we do this throughout the course, that may help call things out better and improve readability.
| --- | ||
|
|
||
| In Java, we use operators to perform to change or compare the values of variables. | ||
| There are different types of operators, which are: |
There was a problem hiding this comment.
| There are different types of operators, which are: | |
| There are four different types of operators, which are: |
| <td>a++</td> | ||
| </tr> | ||
| <tr> | ||
| <td>--</td> |
There was a problem hiding this comment.
Is there any way we could make this have a small space in the middle to make it clear that it's two -? In my browser at work (chrome), it's showing as just a big horizontal line so it isn't entirely clear what it is. Maybe put it inside a single-tick code block?
| <summary>Answer</summary> | ||
| <div class="content"> | ||
| <p> | ||
| * answer1 is 6 because 2 + 4 = 6 * answer2 is 2 because 6 / 3 = 2 * |
There was a problem hiding this comment.
This should really be broken onto multiple lines. Currently, it renders all on one line.
| <summary>Answer</summary> | ||
| <div class="content"> | ||
| <p> | ||
| Number's new value is 12. This is because Number holds the value 6. |
There was a problem hiding this comment.
Number is the name of a built in class in java. I'd probably change this just to avoid confusion. Lowercase number should be fine.
| be a double instead of an int. | ||
| </Aside> | ||
|
|
||
| The ++ and -- operators are often used to change the value of the code as well. |
There was a problem hiding this comment.
Same thing with -- in this paragraph
| <tr> | ||
| <td>{'=='}</td> | ||
| <td> | ||
| Equals to: Checks if one value is the same values as the other |
There was a problem hiding this comment.
| Equals to: Checks if one value is the same values as the other | |
| Equal to: Checks if one value is the same values as the other |
| <tr> | ||
| <td>{'>='}</td> | ||
| <td> | ||
| Greater than or equal too: Checks if one value is greater than |
There was a problem hiding this comment.
| Greater than or equal too: Checks if one value is greater than | |
| Greater than or equal to: Checks if one value is greater than |
| <tr> | ||
| <td>{'<='}</td> | ||
| <td> | ||
| Less than or equal too: Checks if one value is less than or |
There was a problem hiding this comment.
| Less than or equal too: Checks if one value is less than or | |
| Less than or equal to: Checks if one value is less than or |
| <tbody> | ||
| <tr> | ||
| <td>{'&&'}</td> | ||
| <td>and: true if both statements are true</td> |
There was a problem hiding this comment.
| <td>and: true if both statements are true</td> | |
| <td>And: true if both statements are true</td> |
| </tr> | ||
| <tr> | ||
| <td>{'!'}</td> | ||
| <td>Not: reverses. If true, then false. If false then true </td> |
There was a problem hiding this comment.
| <td>Not: reverses. If true, then false. If false then true </td> | |
| <td>Not: reverses. If true, then false. If false, then true </td> |
Added information about operators for stage 0
It includes: Arithmetic, Assignment, Comparison and Logical operators.
No exercise yet but I plan to add one in after all stage 0 material is written