Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
352 changes: 176 additions & 176 deletions src/SUMMARY.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/arguments/challenges.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Remember the rules for this are
- Try to use only the information given up to this point in this book.
- Try not to give up until you've given it a solid attempt

## Challenge 1.
## Challenge 1

Write a method named `printSquare` which takes one `int` argument named `size`.

Expand All @@ -29,7 +29,7 @@ void main() {
}
```

## Challenge 2.
## Challenge 2

What happens if a negative number is given to your `printSquare`?

Expand All @@ -52,4 +52,4 @@ void main() {
}
```

## Challenge 3.
## Challenge 3
22 changes: 13 additions & 9 deletions src/arguments/overloading.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ Multiple methods can be declared that have the same name.
This is allowed so long as each method takes different types
or different numbers of arguments.

Let's say you're a chef, you want to make a sandwich. You know multiple ways to make sandwich, maybe a basic sandwich? add some more filling etc

```java
void doThing(int x) {
System.out.println(x);
void makeSandwich() {
System.out.println("makes a basic sandwich");
}

void doThing(String name) {
System.out.println("Hello " + name);
void makeSandwich(String ingredientOne) {
System.out.println("makes a sandwich with added ingredientOne");
}

void doThing(int x, int y) {
System.out.println(x + y);
void makeSandwich(String ingredient1, String ingredient2, String ingredient3) {
System.out.println("makes a sandwich with ingredient1, ingredient2 and ingredient3");
}
```

Expand All @@ -25,15 +27,17 @@ you are passing.
```java
void main() {
// Java can figure out what to do
doThing(1);
doThing("abc");
doThing(1, 2);
makeSandwich();
makeSandwich("Lettuce");
makeSandwich("Lettuce","tomato","Onion");
}
```

When there are multiple methods that have the same name but take different arguments,
those methods are considered "overloads" of eachother[^overload]

Note: You can have as many methods you want with same name as long as each has at least one different arguement.

[^overload]:
"Overloading" in this context means when one word has more than
one possible meaning depending on how it is used. Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.
2 changes: 1 addition & 1 deletion src/loops/break.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ while (true) {
"The people started singing it not knowing what it was"
);

// Will immediately leave the loop
// Will immediately leave the current loop
break;
}
```
24 changes: 12 additions & 12 deletions src/loops_ii/challenges.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ case to handle. Its for your own good, I hope.

Write code that will output every number from 0 to 15, including 0 and 15.

```
```text
0
1
2
Expand All @@ -38,7 +38,7 @@ Do it using a `for` loop and again using a `while` loop.

Write code that will output every number from 15 to 0, including 0 and 15.

```
```text
15
14
13
Expand All @@ -63,7 +63,7 @@ Do it using a `for` loop and again using a `while` loop.

Write code that will output every number from 15 to 0, excluding 0 and 15.

```
```text
14
13
12
Expand All @@ -82,11 +82,11 @@ Write code that will output every number from 15 to 0, excluding 0 and 15.

Do it using a `for` loop and again using a `while` loop.

## Challenge 4.
## Challenge 4

Write code that will output every third number from 51 to 66.

```
```text
53
56
59
Expand All @@ -96,41 +96,41 @@ Write code that will output every third number from 51 to 66.

Do it using a `for` loop and again using a `while` loop.

## Challenge 5.
## Challenge 5

Draw a square.

Make it so that you can make the square bigger or smaller by
changing a variable at the start of the program.

```
```text
*****
*****
*****
*****
```

## Challenge 6.
## Challenge 6

Draw a rectangle.

Make it so that you can make the rectangle bigger or smaller in either dimension by
changing a variable at the start of the program.

```
```text
******
******
******
```

## Challenge 7.
## Challenge 7

Draw a circle!

Make it so that you can make the circle bigger or smaller by
changing a variable at the start of the program.

```
```text
**
****
******
Expand All @@ -140,7 +140,7 @@ changing a variable at the start of the program.
**
```

## Challenge 8.
## Challenge 8

Draw a smiley face!

Expand Down
4 changes: 2 additions & 2 deletions src/loops_ii/drawing_isosceles_triangles.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Another fun shape is the isosceles triangle.

```
```text
*
***
*****
Expand Down Expand Up @@ -33,7 +33,7 @@ for (int row = 1; row <= totalRows; row++) {
}
```

```
```text
*
***
*****
Expand Down
4 changes: 2 additions & 2 deletions src/loops_ii/drawing_right_triangles.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ One of the more fun things to do with `for` loops[^quiz] is to use them to print

Say you wanted to draw this right triangle.

```
```text
*
**
***
Expand Down Expand Up @@ -44,7 +44,7 @@ for (int numberOfStars = 1; numberOfStars <= height; numberOfStars++) {
}
```

```
```text
*
**
***
Expand Down
6 changes: 3 additions & 3 deletions src/methods/challenges.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Remember the rules for this are
- Try to use only the information given up to this point in this book.
- Try not to give up until you've given it a solid attempt

## Challenge 1.
## Challenge 1

Declare a method named `printSquare`. When invoked it should print a square.

Expand All @@ -17,7 +17,7 @@ void main() {
}
```

## Challenge 2.
## Challenge 2

Declare a method named `printSquareThreeTimes`. When invoked it should print three squares
by invoking a method named `printSquare` three times.
Expand All @@ -32,7 +32,7 @@ void main() {
}
```

## Challenge 3.
## Challenge 3

Write a program that contains at least four methods. Have fun with it.

Expand Down