Skip to content
Open
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
45 changes: 45 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Deploy Quartz site to GitHub Pages

on:
push:
branches:
- v4

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for git info
- uses: actions/setup-node@v3
with:
node-version: 18.14
- name: Install Dependencies
run: npm ci
- name: Build Quartz
run: npx quartz build
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: public

deploy:
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
File renamed without changes.
25 changes: 25 additions & 0 deletions content/Conditionals or Selections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
if statements n stuff

### Short-circuit evaluation
```java
int x = 10;
int y = 0;
// It will skip the second condition b/c the first condition is true
if (x < 20 || x / y == 0) {
// It will print this; no runtime error
}
if (x < 20 && x / y == 0) {
// This will throw a run-time error because && will run both conditionals.
// The conditional for x / y will give an arithmetic error
}

```

### Syntactic sugar
```java
// Will call the line directly after if there's no curly brackets '{}'
if (true) System.out.println("This will print if true!");

System.out.println("This will print regardless!");

```
4 changes: 4 additions & 0 deletions content/De Morgan's Law.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# NOOOOooooo !

![[Pasted image 20240220132055.png]]![[Pasted image 20240220132805.png]]
![[Pasted image 20240220133100.png]]
24 changes: 24 additions & 0 deletions content/Flow charts for conditionals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
flow charts yay
* Oval = beginning
* parallelogram
* Assigning variables
* Getting user input
* Output
* Diamond = conditions
* Square
* Describes a condition (true / false arrow)


Note:
* Do not write exact code



The top image is an oval that says "start"
![[Pasted image 20240221144302.png]]

(newer)
![[Pasted image 20240222132119.png]]

- The point of the parallelogram is to specify input and output.
-
43 changes: 43 additions & 0 deletions content/For loops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

```java
// This will loop so long as i, which is declared *inside* the for loop, is less than 10. If it isn't, the loop will not continue.
for (int i = 0; i < 10; i++) {
// I will be the values between [0, 9]
}
```

```java
int i;
// This for loop doesn't have a body, so it just makes i equal to 9 at the end of the loop.
for (i = 0; i < 10; i++);
s.o.p(i); // Will print 9
```

```java
// Similarly to conditionals, if you don't add the curly braces or semicolon, it will only loop the line right after it.
for (int i = 0; i < 10; i++)
s.o.p(i); // Prints 0 to 9
s.o.p("This is only printed once!");
```

## Semantics with ++
The "++" operator can be written two ways:
```java
int variable = 0;
variable++; // First way
++variable; // Second way
```
...and there is a big difference between the two of them!1
1. `var++` will get the value of `var`, and *then* increment by one
2. `++var` will increment the value, and then will give that incremented value of `var`
>[!help] Yes. it doesn't make much sense at first. Bear with me

```java
int first = 0;
System.out.println(first++); // "0" is printed, then "first" increments by 1.

int second = 0;
System.out.println(++second); // "second" will be incremented, and then "1" is printed.
```
>In both cases, `first` and `second` increment by 1, but the time at which the variables "update" is different

116 changes: 116 additions & 0 deletions content/GUI's.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
A window is a "`JFrame`"
- Dimensions are in pixels
- (0,0) is at the top left (like Godot)
- Widgets are the components:
- `TextLabel`s
- Will display words
- Buttons
- `TextField`
- Will allow user input
- `TextArea`
- `CheckBox`
* Output can be a label (most common)
* All widgets are rectangular and they are placed via the top-left corner's position

E.g: a label is 200 by 50. The Frame is 500 by 500. How do we center it?
- y: 250 - 25 = 225 y
- x: 250 - 100 = 150 x
- Rect Coords: (150, 225)




* Main isn't used very much
* If we want to make a Gui, make a new file called frmMyGui
* All forms will start with "frm"
* All the imports will be copy-pasted
* Dw about what `extends` and `implements` mean; really.
* Instance the GUI inside of main:
* ![[Pasted image 20240227141600.png]]

> here is the file frmMyGui.java
![[Pasted image 20240227141453.png]]


### Frame methods
> Inside of frmMyGUI's constructor
![[Pasted image 20240227141708.png]]

### Instancing custom colors
![[Pasted image 20240227141748.png]]

### Defining new widgets on a frame
![[Pasted image 20240227142036.png]]
> Declare it first
>
```java
public class frmMyFrame extends JFrame implements ActionListener
{
// Declare variable
JLabel lblTitle;
JTextField txtName;
JButtom btnEnter;

public frmMyFrame()
{
setLayout(null); // This will give "full control" over where labels go

// Instance it
lblTitle = new JLabel("Welcome to my GUI");
// These can now be controlled b/c setLayout is null.
lblTitle.setSize(200, 50);
lblTitle.setLocation(150, 0);
// Required to see the widget
add(lblTitle);


// Setting up a text field
txtName = new JTextField(); // Nothing required to instance
txtName.setLocation(150, 50);
txtName.setSize(100, 50);
add(txtName);


// Lastly, a button for example
btnEnter = new JButton("Enter");
btnEnter.setSize(150, 200);
btnEnter.setLocation(100, 50);
add(btnEnter;)
}
}
```
> [!Note] If two widgets are on the same spot, they're cover eachother up! Be careful about that


## Coding the GUI's
* All buttons have "Actions"
* Before adding a button, you need these 2 lines of code to make the button do something.
```java

public frmMyFrame() {
btnEnter = new JButton("Enter");
btnEnter.setSize(150, 200);
btnEnter.setLocation(100, 50);
// New lines
btnEnter.setActionComment("enter");
btnEnter.setActionListener(this);
// Remember to add
add(btnEnter;)
}

public void actionPerformed(ActionEvent e) {
if (e.getActionComment.equals("enter")) {
// Code is triggered when the button is pressed
}
}
```

## Getting text from TextLabel
```java
// It's this simple! txtName is a JTextLabel
String text = txtName.getText();

double dblValue = 10.41;
txtName.setText("" + dblValue); // Set text always takes in a string. A double is not a string, so we concatenate with the "+"
```

7 changes: 7 additions & 0 deletions content/Input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```java
Scanner input = new(System.in);

int __ = input.nextInt(); //-- Int
double __ = input.nextDouble(); //-- double
String __ = input.next(); //-- string
```
3 changes: 3 additions & 0 deletions content/Interpreter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
One part of the Java Virtual Machine ([[JVM]]) is its interpreter, which is then used to run code for difference devices.

Java does have a JIT compiler, which compiles the byte-code into machine code right before being ran by the [[JVM]] (Yes, still. Even as machine code the [[JVM]] is still significant in running Java code) for performance gains by working with hardware more closely (sort of like lower-level languages)
10 changes: 10 additions & 0 deletions content/JVM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Java code is ran via the JVM, which:
1. Uses its [[Interpreter]] to read the byte-code given by the [[Java Compiler]]
2. Runs its JIT compiler for optimization optionally
3. Runs the code for every device.

> Therefore, Java is kind of *both* interpreted and compiled, but not* fully* interpreted and not *fully* compiled




1 change: 1 addition & 0 deletions content/Java Compiler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The compiler is what turns text code into byte-code (going from .java to .class files). It is used preliminarily in order for the JVM to interpret the code. Unlike python, where every line is read *raw*.
43 changes: 43 additions & 0 deletions content/Jegification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 1 Indent using this format:
![[Pasted image 20240205141354.png]]
# 2 Header
The header will be like this:
```java
/**
Author:
Date:
Description:
**/
```
# 3 No commented-out code
Do not submit code with the backslashes (or it should run even with the backslashes on lines)

# 4 Pretty math
Add spaces between all arithmetic
```java
int value = (x + 6) / 4
```

# 5 Variable names
All variable names need to have the data type before them
```java
int intValue = 10;
double dblValue = 2.5;

String strPain = "Welcome to jegified land";
```

# 6 Comment everything
Always describe what a variable does when you declare it (EVERY ONE); don't just say you declared it
```java
// intJohn is an integer variable to store John's age
int intJohn;
```

# 7 All scanners shall be named "input"

# 8 Break? More like i'll snap your neck in half
* You can only use "break" in switch-cases

# 9 [[Strings||String]] methods
Only `length()`, `substring()`, and `indexOf()` are allowed
6 changes: 6 additions & 0 deletions content/Low-level and High-level languages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
According to Jeg:
- Low-level = compiled (no errors until you run the code)
- High-level = interpreted (you can see errors before compilation)

>[!note] Java is high-level

Binary file added content/Pasted image 20240205141354.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/Pasted image 20240220132055.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/Pasted image 20240220132805.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/Pasted image 20240220133100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/Pasted image 20240221144302.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/Pasted image 20240222132119.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/Pasted image 20240227141453.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/Pasted image 20240227141543.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/Pasted image 20240227141557.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/Pasted image 20240227141600.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/Pasted image 20240227141708.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/Pasted image 20240227141748.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/Pasted image 20240227142036.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions content/Strings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
```java
String string = "Everything inside these (besides escape sequences and quotes) will be allowed in a string"

```

Methods
```java
String myString = "I love MELONS";

int length = myString.length(); // Gets length
char firstChar = myString.charAt(0); // Indexes start at 0. You are not allowed to use this

int index = myString.indexOf("l"); // Gets index of first instance of a string. if there's none, it will give "-1"
int index2 = myString.indexOf("love"); // Also possible; would be the same as the index above.

String sub = myString.substring(0, 2); // Will get the character at index 0 up to the index before 2. Its range is basically [0, 2)
String sub2 = myString.substring(3) // Will return everything after and including index 3

String upper = myString.toUpperCase(); // Makes things upper case
String lower = myString.toLowerCase();
```
>[!Note] You can ONLY use the methods `length()`, `substring()`, and `indexOf()` for strings
### Reading strings as input
```java
Scanner input = new Scanner(System.in);
input.next();
```


## Comparing strings
```java
// You cannot use double-equal signs. it will not work
String temp = "My string";
if (temp.equals("My string")) {
// Will run this block because every character is the same
}
```

### compareto
``` java
String s1 = "Apple", s2 = "Boy";
// The method "compareTo" compare every character's ASCII value
if (s1.compareTo(s2) == 0) {
// S1 has the same ASCII characters as s2
}
if (s1.compareTo(s2) < 0) { // it returns a random negative value
// s1 comes earlier alphabetically than s2.
// "A" is index 65 and "B" is index 66. Since 65 < 66, the function returns a value less than 0
}
if (s2.compareTo(s1) > 0) {
// compareTo will return a positive value because
}
```
Loading