Skip to content

Commit a74126d

Browse files
authored
Merge pull request #8 from code-for-tomorrow/ch10-exercises
Ch10 exercises, new workflows, and prettified java code
2 parents 57bdfc3 + 5c047b8 commit a74126d

File tree

154 files changed

+3298
-2805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+3298
-2805
lines changed

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore workflow files
2+
*.yml
3+
4+
# Ignore markdown files
5+
*.md

.prettierrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"tabWidth": 4,
3+
"semi": false,
4+
"bracketSpacing": false
5+
}

src/com/codefortomorrow/beginner/chapter1/examples/Comments.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.codefortomorrow.beginner.chapter1.examples;
22

33
public class Comments {
4-
// This is a single line comment
5-
/*
4+
// This is a single line comment
5+
/*
66
This is
77
a multi-line
88
comment
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.codefortomorrow.beginner.chapter1.examples;
22

33
public class HelloWorld {
4-
public static void main(String[] args) {
5-
System.out.println("Hello World! I am the master of swag");
6-
System.out.println("Hello World! I am awesome");
74

8-
// System.out.print("Hello World! I am the master of swag");
9-
// System.out.print("Hello World! I am awesome");
10-
}
5+
public static void main(String[] args) {
6+
System.out.println("Hello World! I am the master of swag");
7+
System.out.println("Hello World! I am awesome");
8+
// System.out.print("Hello World! I am the master of swag");
9+
// System.out.print("Hello World! I am awesome");
10+
}
1111
}

src/com/codefortomorrow/beginner/chapter1/practice/AboutMe.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
*/
1313

1414
public class AboutMe {
15-
public static void main(String[] args) {
16-
// write code here
17-
}
15+
16+
public static void main(String[] args) {
17+
// write code here
18+
}
1819
}

src/com/codefortomorrow/beginner/chapter1/solutions/AboutMe.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,33 @@
1212
*/
1313

1414
public class AboutMe {
15-
public static void main(String[] args) {
16-
// print my name
17-
System.out.print("Inej Ghafa ");
1815

19-
// print a message
20-
System.out.println("No mourners, no funerals.");
16+
public static void main(String[] args) {
17+
// print my name
18+
System.out.print("Inej Ghafa ");
2119

22-
// print a poem
23-
System.out.println("Shall I tell you the secret of true love?");
24-
System.out.println("A friend of mine liked to tell me that women love flowers");
25-
System.out.println("Many boys will bring you flowers.");
26-
System.out.println("But someday you'll meet a boy who will learn your favorite flower,");
27-
System.out.println("your favorite song,");
28-
System.out.println("your favorite sweet.");
29-
System.out.println("And even if he is too poor to give you any of them,");
30-
System.out.println("it won't matter because he will have taken the time");
31-
System.out.println("to know you as no one else does.");
32-
System.out.println("Only that boy earns your heart.");
33-
System.out.println("-Leigh Bardugo, Six of Crows");
34-
}
20+
// print a message
21+
System.out.println("No mourners, no funerals.");
22+
23+
// print a poem
24+
System.out.println("Shall I tell you the secret of true love?");
25+
System.out.println(
26+
"A friend of mine liked to tell me that women love flowers"
27+
);
28+
System.out.println("Many boys will bring you flowers.");
29+
System.out.println(
30+
"But someday you'll meet a boy who will learn your favorite flower,"
31+
);
32+
System.out.println("your favorite song,");
33+
System.out.println("your favorite sweet.");
34+
System.out.println(
35+
"And even if he is too poor to give you any of them,"
36+
);
37+
System.out.println(
38+
"it won't matter because he will have taken the time"
39+
);
40+
System.out.println("to know you as no one else does.");
41+
System.out.println("Only that boy earns your heart.");
42+
System.out.println("-Leigh Bardugo, Six of Crows");
43+
}
3544
}
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package com.codefortomorrow.beginner.chapter2.examples;
22

33
public class BallDrop {
4-
public static void main(String[] args) {
5-
System.out.println("Hello world!");
6-
System.out.println("The ball dropped \n\t down \n\t\t down \n\t\t\t down");
7-
}
4+
5+
public static void main(String[] args) {
6+
System.out.println("Hello world!");
7+
System.out.println(
8+
"The ball dropped \n\t down \n\t\t down \n\t\t\t down"
9+
);
10+
}
811
}
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package com.codefortomorrow.beginner.chapter2.examples;
22

33
public class FormattingText {
4-
public static void main(String[] args) {
5-
String firstName = "Jyoti";
6-
String lastName = "Rani";
7-
System.out.println("First name: " + firstName + "\nLast name: " + lastName);
8-
}
4+
5+
public static void main(String[] args) {
6+
String firstName = "Jyoti";
7+
String lastName = "Rani";
8+
System.out.println(
9+
"First name: " + firstName + "\nLast name: " + lastName
10+
);
11+
}
912
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package com.codefortomorrow.beginner.chapter2.examples;
22

33
public class Name {
4-
public static void main(String[] args) {
5-
String firstName = "Jyoti";
6-
String lastName = "Rani";
7-
System.out.println(firstName + lastName);
8-
}
4+
5+
public static void main(String[] args) {
6+
String firstName = "Jyoti";
7+
String lastName = "Rani";
8+
System.out.println(firstName + lastName);
9+
}
910
}
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
package com.codefortomorrow.beginner.chapter2.examples;
22

33
public class Variables {
4-
public static void main(String[] args) {
5-
String name; // declaration
6-
name = "Kaz"; // initialization
7-
// String name = "Kaz"; // one step
84

9-
// initialization and declaration in one line
10-
String firstName = "Kaz", lastName = "Brekker";
5+
public static void main(String[] args) {
6+
String name; // declaration
7+
name = "Kaz"; // initialization
8+
// String name = "Kaz"; // one step
119

12-
// declaration in one line
13-
String address, message;
10+
// initialization and declaration in one line
11+
String firstName = "Kaz", lastName = "Brekker";
1412

15-
name = "Hello"; // assign a new value to name
13+
// declaration in one line
14+
String address, message;
1615

17-
final int CENTS_PER_DOLLAR = 100; // constant
18-
}
16+
name = "Hello"; // assign a new value to name
17+
18+
final int CENTS_PER_DOLLAR = 100; // constant
19+
}
1920
}
2021

2122
// scope
2223
class A {
23-
String message = "World";
24+
String message = "World";
2425
}
2526

2627
class B {
27-
String word = "Java";
28+
String word = "Java";
2829
}

0 commit comments

Comments
 (0)