Skip to content

Commit 10bc5fe

Browse files
committed
[wip] update java curriculum website
1 parent aabdfce commit 10bc5fe

7 files changed

Lines changed: 195 additions & 2 deletions

File tree

source/classes-workshops/intro-java.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,31 @@
99
* Twice a week, 1 hour per class
1010
* 2-3 weeks
1111

12-
## Classes
12+
## Course material
13+
14+
We didn't get much done in the first class except for installation + setup.
15+
16+
* [Installation and setup](intro-java/setup.md)
17+
* [How to disable the AI in VSCode](intro-java/disable-ai.md)
18+
* [Java basics](intro-java/1-java-basics.md)
19+
* [Control flow](intro-java/2-control-flow.md)
20+
21+
## Class schedule
1322

1423
* Sep 24, 16:30~17:30 (4:30-5:30pm) - Java syntax (and environment setup)
15-
* Sep 25, 18:00~19:00 (6-7pm) - Control flow
24+
* [Sep 25, 18:00~19:00 (6-7pm) - Control flow](intro-java/2-control-flow.md)
1625
* Oct 1, 16:30~17:30 (4:30-5:30pm) - Methods and classes
1726
* Oct 2, 18:00~19:00 (6-7pm) - Object-oriented design and recursion
1827
* TBD - Final project
1928

29+
:::{toctree}
30+
:maxdepth: 2
31+
:caption: Contents
32+
:titlesonly: true
33+
:hidden: true
2034

35+
setup.md
36+
disable-ai.md
37+
1-java-basics.md
38+
2-control-flow.md
39+
:::
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 1 - Java basics
2+
3+
[Slides](https://docs.google.com/presentation/d/1VA7ocVVXC-tunyf3piNGs9KYpv3fgJ83Aov8dU23EOQ/edit?slide=id.g36a207f0c2e_0_19#slide=id.g36a207f0c2e_0_19)
4+
5+
These slides were not what was presented during the class; the setup guide and some confusing information were removed.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# 2 - Intro and Control flow
2+
3+
[Slideshow](https://docs.google.com/presentation/d/1guorgyU68cKTfepvvsMLYtrrQHuN8Rys6UL-r0_Ztsk/edit)
4+
5+
The recording will be published as soon as possible.
6+
7+
The class went over:
8+
* Java basics (recap of [lesson 1](1-java-basics.md))
9+
* Conditionals
10+
* For and while loops
11+
12+
## Guide
13+
14+
%% TODO
15+
16+
## Demonstrated code
17+
```{code-block} java
18+
:caption: App.java
19+
:lineno-start: 1
20+
21+
public class App {
22+
public static void main(String[] args) throws Exception {
23+
System.out.println("Hello, World!");
24+
String str1 = "first string";
25+
str1 = "second string";
26+
System.out.println(str1);
27+
28+
int numOne = 4;
29+
int numTwo = 9;
30+
int numSum = numOne + numTwo;
31+
int numDiff = numOne - numTwo;
32+
int numProd = numOne * numTwo;
33+
int numQuot = numOne / numTwo;
34+
System.out.println(numSum);
35+
System.out.println(numDiff);
36+
System.out.println(numProd);
37+
System.out.println(numQuot);
38+
39+
int a = 5;
40+
int b = 10;
41+
42+
if (a==b){
43+
System.out.println("a = b");
44+
}
45+
else if (a<b){
46+
System.out.println("a < b");
47+
}
48+
else{
49+
System.out.println("a > b");
50+
}
51+
52+
if (a < 10 && b > 5){
53+
System.out.println("a is less than 10 AND b is greater than 5");
54+
}
55+
else if (a < 10 || b < 5 || !(a==b)) {
56+
System.out.println("a is less than 10 OR b is less than 5");
57+
}
58+
else if (a!=b) {
59+
System.out.println("a is NOT equal to b");
60+
}
61+
else {
62+
System.out.println("neither of the conditions were true");
63+
}
64+
int j = 0;
65+
while (j<5){
66+
System.out.println("j is currently: " + j);
67+
j++;
68+
}
69+
70+
for (int y = 0; y<=3; y++){
71+
System.out.println("Outer loop y = " + y);
72+
for (int z = 1; z <=2; z++){
73+
System.out.println(" Inner loop z = " + z);
74+
}
75+
}
76+
}
77+
}
78+
```
79+
80+
## Exercise
81+
82+
* Write a program to check if the grade percentage in a variable is an A, B, C, or D.
83+
* A = 90+, B = 80+, C = 70+, D = 0-69.9
84+
* Use a loop to go through numbers from 50 to 94, inclusive
85+
* In increments of 4
86+
87+
* Hint:
88+
* Think about what type of loop would be better
89+
* How you would increase something by 4 and use it?
90+
91+
### Solution
92+
93+
:::{dropdown} Solution
94+
```{code-block} java
95+
:caption: GradeChecker.java
96+
:lineno-start: 1
97+
98+
public class GradeChecker {
99+
public static void main(String[] args) {
100+
// Loop from 50 to 94 in increments of 4
101+
for (int grade = 50; grade <= 94; grade += 4) {
102+
// Check grade category
103+
if (grade >= 90) {
104+
System.out.println("Grade " + grade + " = A");
105+
} else if (grade >= 80) {
106+
System.out.println("Grade " + grade + " = B");
107+
} else if (grade >= 70) {
108+
System.out.println("Grade " + grade + " = C");
109+
} else {
110+
System.out.println("Grade " + grade + " = D");
111+
}
112+
}
113+
}
114+
}
115+
```
116+
:::
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Disable AI features
2+
3+
TODO
22.7 KB
Loading
21.3 KB
Loading
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Setting up Java environment
2+
3+
## Java Development Kit
4+
5+
::::{tab-set}
6+
:sync-group: os
7+
8+
:::{tab-item} Windows
9+
:sync: win
10+
11+
There are many JDKs (Java Development Kits) available online but [Temurin](https://adoptium.net/) is a great option. Choose [Temurin JDK 21 LTS (use the `.msi` installer)](https://adoptium.net/temurin/releases/?package=jdk&version=21&os=windows&arch=x64).
12+
13+
Open the `.msi` installer, agree to the license, and when you get to this page:
14+
![Setup](image.png)
15+
16+
Go to **Set JAVA_HOME variable**, click on the little icon, and set that to "Entire feature will be installed on local hard drive":
17+
![Setup with popup](image-1.png)
18+
19+
Then, continue to follow the instructions and install it.
20+
:::
21+
22+
:::{tab-item} Linux
23+
:sync: linux
24+
25+
Your distribution should have a JDK available to download. If you're on Debian, Ubuntu, Mint, or some other `apt`-based distribution, you can install the system-recommended JDK using
26+
```bash
27+
sudo apt install default-jdk
28+
```
29+
30+
If you're on openSUSE:
31+
```bash
32+
sudo zypper in java-21-openjdk java-21-openjdk-devel
33+
```
34+
35+
Ask an upperclassman if you need help
36+
:::
37+
38+
:::{tab-item} macOS
39+
:sync: macos
40+
41+
There are many JDKs (Java Development Kits) available online but [Temurin](https://adoptium.net/) is a great option. Choose [Temurin JDK 21 LTS (use the `.pkg` installer)](https://adoptium.net/temurin/releases/?package=jdk&version=21&os=mac&arch=any).
42+
:::
43+
44+
::::
45+
46+
## Visual Studio Code (VSCode)
47+
48+
Download it from [the website](https://code.visualstudio.com/).
49+
50+
Remember to [disable the AI features](disable-ai.md).

0 commit comments

Comments
 (0)