Skip to content

Commit 3ad07cd

Browse files
committed
elmo full name
1 parent 626bc8d commit 3ad07cd

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

src/classes/the_meaning_of_the_word_class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ a `String` is classified by the set of things you can do to it and the data
99
it stores. The `String` class would specify all of that.[^heady]
1010

1111

12-
[^idiot]: What an [idiot](https://www.shardcore.org/spx/2015/05/15/diogenes-and-the-chicken/)
12+
[^idiot]: What an [idiot](https://penelope.uchicago.edu/encyclopaedia_romana/greece/hetairai/diogenes.html)
1313

1414
[^heady]: If that's a bit too heady of an explanation don't fret. You will likely get it intuitively eventually.
1515
There are like 50 different ways to explain it and eventually one will land for you.

src/floating_point_numbers/equality.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ IO.println(doesWhatYouExpect);
2929
~}
3030
```
3131

32+
To account for that you can check if a number is "close enough" to another one
33+
by seeing if the "absolute value" of the difference is a small number.
34+
35+
```java
36+
~void main() {
37+
double x = 0.1;
38+
double y = 0.2;
39+
// z will be 0.30000000000000004
40+
double z = x + y;
41+
42+
double compare = 0.3;
43+
44+
// this will be true.
45+
boolean doesWhatYouExpect =
46+
Math.abs(z - 0.3) < 0.00001;
47+
48+
IO.println(doesWhatYouExpect);
49+
~}
50+
```
51+
3252
A `double` can also be compared to an `int` and, if they represent the same value, they will be reported as equal.
3353

3454
```java

src/instance_methods/derived_values.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,24 @@ void main() {
2121
}
2222
```
2323

24-
Which is useful for situations like where you store someones first and last name
24+
Which is useful for situations like where you store someones first and last name
25+
but need to ask "what is their full name?"
26+
27+
```java
28+
class Elmo {
29+
String firstName;
30+
String lastName;
31+
32+
String fullName() {
33+
return firstName + " " + lastName;
34+
}
35+
}
36+
37+
void main() {
38+
Elmo elmo = new Elmo();
39+
elmo.firstName = "Elmo";
40+
elmo.lastName = "Furchester";
41+
42+
IO.println("Elmo's full name is " + elmo.fullName());
43+
}
44+
```

0 commit comments

Comments
 (0)