diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..47d5cac0 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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 \ No newline at end of file diff --git a/content/.gitkeep b/content/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/content/2D Arrays.md b/content/2D Arrays.md new file mode 100644 index 00000000..66cf936b --- /dev/null +++ b/content/2D Arrays.md @@ -0,0 +1 @@ +Famous question: Creating minesweeper \ No newline at end of file diff --git a/content/Array Lists.md b/content/Array Lists.md new file mode 100644 index 00000000..387fb5ce --- /dev/null +++ b/content/Array Lists.md @@ -0,0 +1,61 @@ +# YESSSS +- An empty list +- To access it, you use special methods +- The data type between the carets <> must be classes (which are usually uppercase) + +| `Class` | `Not a class` | +| --------- | ------------- | +| Integer | int | +| Character | char | +| Boolean | boolean | +| String | - | +| Scanner | - | + +# Instancing +```java +// Making an arraylist variable; +ArrayList arrayList = new Arraylist(); + +// You can also ignore the type when instancing the array list +ArrayList arrayList = new Arraylist<>(); +``` + +# Methods +We only know: +- add() +- get() +- indexOf() +- remove() +- size() +#### Add +```java +arrayList.add(10); // Adds 10 to the array; now size 1 +arrayList.add(20); // Adds 20 to the array; now size 2 +arrayList.add(0, 1); // Adds 1 at index 0; +arrayList.add(4, 1); // Runtime error, because the array is only of size 3; it's biggest index is 2 and adding another element could at most be index 3. +``` +#### Get +```java +int index1 = arrayList.get(1); // Gets the item at index 1 (arrayLists are also indexed from 0 onwards); +``` +#### Index of +```java +System.out.println(arrayList); // printing arraylists works! +int indexOf10 = arrayList.indexOf(10); // Will find the occurance of 10 in array lists +``` +#### Remove +```java +// Removes the item in index 2. Everything on the right of index 2 is shifted +arrayList.remove(2); +``` +#### Size +```java +// Gets the size of the array. Like length or length() in arrays and strings. +arrayList.size(); +``` + +#### Set +```java +// Sets index 0 to the value of 1000. +arrayList.set(0, 1000); +``` \ No newline at end of file diff --git a/content/Arrays.md b/content/Arrays.md new file mode 100644 index 00000000..9bc26007 --- /dev/null +++ b/content/Arrays.md @@ -0,0 +1,79 @@ +## Data structures +A [[Variables|variable]] holds 1 bit of data at a time. +To hold many values, we can use some data structures: +- 1 dimensional array +- [[2D Arrays|2 dimensional array]] +- [[Array Lists|ArrayList<>]] +- Map<> (Dictionaries) + +Other structures include: +- Stacks +- Queues +- Linked Lists +- Binary Trees +- etc + +# Using arrays +### Declaring +```java +// This declares a 1 dimensional array +int [] intArr1 = new int[5]; +// java will default the values in the array to 0 b/c it's a primary type "int" + +// To set a value, you just index the position +intArr1[0] = 10; // index 0 will have an int value of 10. + +// Another way of declaring an array is via curly brackets +// You do not need to "new" anything; just the brackets work. +int [] intArr2 = {1, 2, 3, 4, 5}; +``` +### ArrayIndexOutOfBoundsException +```java +int [] intArr1 = new int[5]; +intArr1 = 10; +System.out.println(intArr[0]); // Will print 10 +intArr1[5] = 10; // Will throw a *runtime error* because 5 is outside the range of [0, 4]. Code before will run, but once it reaches this line it will break. +``` + +### Array Methods +```java +int [] intArr1 = new int[5]; +int length = intArr1.length; // Will be 5 +// We use intArr1.length INSTEAD OF "string".length(); because an array has a constant length. + +``` + + +# Passing arrays into methods +I made an example. Just look at it; it is very straight forward. +```java +/* +@param intArr is an integer array +@return the sum of all the elements +*/ +public static int arraySum(int[] intArr) { + int intSum = 0; + + // This is an example of using "for each" + for (int k : intArr) + intSum += k; + return intSum; +} +``` + +# Misc info +Some common algorithms we need to know: +- Finding Max / Min +- Sorting + +Use [[2D Arrays]] for grids and stuff + +Arrays are a constant size. +Use an ArrayList<> for dynamically sizing array. +Use a Map to hold a pair of data. Like a dictionary. + +## What happens if you literally print an array!? +```java +int[] array = new int[1]; +System.out.println(array); // this will print a memory location in hexadecimal (base 16) +``` \ No newline at end of file diff --git a/content/Conditionals or Selections.md b/content/Conditionals or Selections.md new file mode 100644 index 00000000..be47c350 --- /dev/null +++ b/content/Conditionals or Selections.md @@ -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!"); + +``` \ No newline at end of file diff --git a/content/De Morgan's Law.md b/content/De Morgan's Law.md new file mode 100644 index 00000000..35406b3c --- /dev/null +++ b/content/De Morgan's Law.md @@ -0,0 +1,14 @@ + +| Express-
ion | **A** | **B** | A \|\| B | A && B | !A | !B | !A \|\| !B | !A && !B | +| --------------- | ----- | ----- | ------------ | -------------- | --- | --- | ---------- | ------------ | +| | T | T | T | T | F | F | F | F | +| | T | F | T | F | F | T | T | F | +| | F | T | T | F | T | F | T | F | +| | F | F | F | F | T | T | T | T | +| Same
as | | | ! (!A && !B) | ! (!A \|\| !B) | | | !(A && B) | ! (A \|\| B) | + + +![[Pasted image 20240220132055.png]]![[Pasted image 20240220132805.png]] +![[Pasted image 20240220133100.png]] + + diff --git a/content/Flow charts for conditionals.md b/content/Flow charts for conditionals.md new file mode 100644 index 00000000..1c933008 --- /dev/null +++ b/content/Flow charts for conditionals.md @@ -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. +- \ No newline at end of file diff --git a/content/For loops.md b/content/For loops.md new file mode 100644 index 00000000..0a9d8f55 --- /dev/null +++ b/content/For loops.md @@ -0,0 +1,55 @@ + +```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!"); +``` + +## For each +To iterate over every item in an [[Arrays|array]] without needing the index, you can use a for each loop +```java +int[] intArr = {1,2,3,4,5}; +// The variable represents 1 item in the array. +for (int k : intArr) { + // do whatever you want with k, and the loop will continue until all "k"'s are used up. +} + +``` + +## 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 + + diff --git a/content/GUI's.md b/content/GUI's.md new file mode 100644 index 00000000..d2dc88a2 --- /dev/null +++ b/content/GUI's.md @@ -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 "+" +``` + diff --git a/content/Indentation style.md b/content/Indentation style.md new file mode 100644 index 00000000..eb9546ff --- /dev/null +++ b/content/Indentation style.md @@ -0,0 +1,8 @@ +Here's a quick guide: +![[Pasted image 20240326132103.png]] + + + + +This is useless information but i thought it was funny +We never went over this in class; move along \ No newline at end of file diff --git a/content/Input.md b/content/Input.md new file mode 100644 index 00000000..488cc66d --- /dev/null +++ b/content/Input.md @@ -0,0 +1,7 @@ +```java +Scanner input = new(System.in); + +int __ = input.nextInt(); //-- Int +double __ = input.nextDouble(); //-- double +String __ = input.next(); //-- string +``` diff --git a/content/Interpreter.md b/content/Interpreter.md new file mode 100644 index 00000000..930887bb --- /dev/null +++ b/content/Interpreter.md @@ -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) \ No newline at end of file diff --git a/content/JVM.md b/content/JVM.md new file mode 100644 index 00000000..f9a65866 --- /dev/null +++ b/content/JVM.md @@ -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 + + + + diff --git a/content/Java Compiler.md b/content/Java Compiler.md new file mode 100644 index 00000000..ef571207 --- /dev/null +++ b/content/Java Compiler.md @@ -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*. \ No newline at end of file diff --git a/content/Jegification.md b/content/Jegification.md new file mode 100644 index 00000000..49235508 --- /dev/null +++ b/content/Jegification.md @@ -0,0 +1,45 @@ +# 1 Use the Allman [[Indentation style]]: +![[Pasted image 20240205141354.png]] +It looks like the above, where the brackets are on a new line. Replit likes to force K&R so watch out for that. +# 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 String methods +They are specified in the notes about [[Strings]] + diff --git a/content/Low-level and High-level languages.md b/content/Low-level and High-level languages.md new file mode 100644 index 00000000..7621f845 --- /dev/null +++ b/content/Low-level and High-level languages.md @@ -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 + diff --git a/content/Methods.md b/content/Methods.md new file mode 100644 index 00000000..2b86913a --- /dev/null +++ b/content/Methods.md @@ -0,0 +1,35 @@ +I love methods !11 + +For now, to declare a method you start it with `public static` and the data type it returns (`void` for nothing) +#### Methods with a return type +```java +// int is the return type; now we MUST call "return" in the method +public static int sum(int intA, int intB) +{ + return intA + intB; +} +``` +* Every branch of your code must have a return +` +```java +public static boolean isEven(int intA) +{ + if (intA % 2 == 0) return true; + // this will throw an error b/c there is no return statement for when the if statement is "false" +} +``` + +### Naming +- Camel case (lower case first letter) +- It should always be some sort of "action" + +### JavaDoc +```java +/** +@param intA is an integer +@param intB is an integer +@return the sum of intA and intB +**/ +public static int sum(int intA, int intB) {...} +``` +* They must be super concise; no paragraphs needed \ No newline at end of file diff --git a/content/Pasted image 20240205141354.png b/content/Pasted image 20240205141354.png new file mode 100644 index 00000000..44521fed Binary files /dev/null and b/content/Pasted image 20240205141354.png differ diff --git a/content/Pasted image 20240220132055.png b/content/Pasted image 20240220132055.png new file mode 100644 index 00000000..67752f57 Binary files /dev/null and b/content/Pasted image 20240220132055.png differ diff --git a/content/Pasted image 20240220132805.png b/content/Pasted image 20240220132805.png new file mode 100644 index 00000000..850c1628 Binary files /dev/null and b/content/Pasted image 20240220132805.png differ diff --git a/content/Pasted image 20240220133100.png b/content/Pasted image 20240220133100.png new file mode 100644 index 00000000..2263d7be Binary files /dev/null and b/content/Pasted image 20240220133100.png differ diff --git a/content/Pasted image 20240221144302.png b/content/Pasted image 20240221144302.png new file mode 100644 index 00000000..9a7bb4ec Binary files /dev/null and b/content/Pasted image 20240221144302.png differ diff --git a/content/Pasted image 20240222132119.png b/content/Pasted image 20240222132119.png new file mode 100644 index 00000000..8f269a1d Binary files /dev/null and b/content/Pasted image 20240222132119.png differ diff --git a/content/Pasted image 20240227141453.png b/content/Pasted image 20240227141453.png new file mode 100644 index 00000000..70865cb1 Binary files /dev/null and b/content/Pasted image 20240227141453.png differ diff --git a/content/Pasted image 20240227141543.png b/content/Pasted image 20240227141543.png new file mode 100644 index 00000000..952dd280 Binary files /dev/null and b/content/Pasted image 20240227141543.png differ diff --git a/content/Pasted image 20240227141557.png b/content/Pasted image 20240227141557.png new file mode 100644 index 00000000..43d805b0 Binary files /dev/null and b/content/Pasted image 20240227141557.png differ diff --git a/content/Pasted image 20240227141600.png b/content/Pasted image 20240227141600.png new file mode 100644 index 00000000..43d805b0 Binary files /dev/null and b/content/Pasted image 20240227141600.png differ diff --git a/content/Pasted image 20240227141708.png b/content/Pasted image 20240227141708.png new file mode 100644 index 00000000..56e7845f Binary files /dev/null and b/content/Pasted image 20240227141708.png differ diff --git a/content/Pasted image 20240227141748.png b/content/Pasted image 20240227141748.png new file mode 100644 index 00000000..cf8b792b Binary files /dev/null and b/content/Pasted image 20240227141748.png differ diff --git a/content/Pasted image 20240227142036.png b/content/Pasted image 20240227142036.png new file mode 100644 index 00000000..af717c25 Binary files /dev/null and b/content/Pasted image 20240227142036.png differ diff --git a/content/Pasted image 20240326132103.png b/content/Pasted image 20240326132103.png new file mode 100644 index 00000000..ddbb1268 Binary files /dev/null and b/content/Pasted image 20240326132103.png differ diff --git a/content/Pasted image 20240327144729.png b/content/Pasted image 20240327144729.png new file mode 100644 index 00000000..2dc2d7e2 Binary files /dev/null and b/content/Pasted image 20240327144729.png differ diff --git a/content/Pasted image 20240327144747.png b/content/Pasted image 20240327144747.png new file mode 100644 index 00000000..5c57cabd Binary files /dev/null and b/content/Pasted image 20240327144747.png differ diff --git a/content/Pasted image 20240327144918.png b/content/Pasted image 20240327144918.png new file mode 100644 index 00000000..b592e7f9 Binary files /dev/null and b/content/Pasted image 20240327144918.png differ diff --git a/content/Pasted image 20240327145039.png b/content/Pasted image 20240327145039.png new file mode 100644 index 00000000..ebc983b4 Binary files /dev/null and b/content/Pasted image 20240327145039.png differ diff --git a/content/Pasted image 20240327145055.png b/content/Pasted image 20240327145055.png new file mode 100644 index 00000000..39a7f8a3 Binary files /dev/null and b/content/Pasted image 20240327145055.png differ diff --git a/content/Random.md b/content/Random.md new file mode 100644 index 00000000..28891e24 --- /dev/null +++ b/content/Random.md @@ -0,0 +1,8 @@ + +Math.random() has a range of [0, 1) + +```java + +int x = (int) (Math.random() * 10) +// Will give a number from 0 to 9, or [0, 9]. It "floors" the number b/c of the type cast +``` \ No newline at end of file diff --git a/content/Strings.md b/content/Strings.md new file mode 100644 index 00000000..57608aac --- /dev/null +++ b/content/Strings.md @@ -0,0 +1,80 @@ +```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; [3,∞) + +String upper = myString.toUpperCase(); // Makes things upper case +String lower = myString.toLowerCase(); +``` +>[!Note] You can ONLY use these methods for strings: +> * `length()` +> * `substring()` +> * `indexOf()` +> * `toUpperCase()` +> * `toLowerCase()` +> +>In some contexts you can also use: +> * `charAt()` +### 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 +} +``` + +## ASCII ? +```java +char x = 'a' // this i show you dec;are character +int a1 = x; // Will turn the character into its ASCII value + +char newChar = (char) (x + 7) // You can cast an integer into a character via the ASCII value + +int asciiValue = (int) x // this explicitly shows how the character is casted into a number to get its ascii value! +``` + + +## Concatination + +```java +String str = ""; + +str += "Here's some content"; +``` \ No newline at end of file diff --git a/content/Switch-case.md b/content/Switch-case.md new file mode 100644 index 00000000..3b32ac15 --- /dev/null +++ b/content/Switch-case.md @@ -0,0 +1,24 @@ +Instead of chaining if-else statements, using a switch is more performant. It also looks like Python. + +```java +int value = 3; +switch(value) { + // You are not allowed to use "break" ANYWHERE ELSE in your code + case 1: System.out.println("Sunday"); + break; // w/o this break the code will print the rest of the cases for some reason. + case 2: System.out.println("Monday"); + break; + case 3: System.out.println("Tuesday"); + break; + default: + System.out.println("Default b/c every other case failed"); + break; + //etc + } +} +``` + +Every case is NOT its own scope. A scope is anything inside those curly brackets: `{}` +This means that if you define a variable in case 1, then case 2 can still access that variable. +#fact-check + diff --git a/content/Times i goofed up.md b/content/Times i goofed up.md new file mode 100644 index 00000000..ecea2e13 --- /dev/null +++ b/content/Times i goofed up.md @@ -0,0 +1,7 @@ +1. System.out.print will print a line w/o a \n. + 1. If you call System.out.print, then System.out.println, it will still print on the same line +2. Tab works like this: + 1. a tab is every 4 characters. if a word is 5 words long, the tab will add 3 spaces to make it a multiple of 4 (which is 8) + 2. Just remember that he is assuming the font is monospace'd +3. % is before division/multiplication + 1. BE%DMAS \ No newline at end of file diff --git a/content/Variables.md b/content/Variables.md new file mode 100644 index 00000000..d0576300 --- /dev/null +++ b/content/Variables.md @@ -0,0 +1,27 @@ +An ATM will store data into the RAM, which stores le variable while the program is running. +It could be stored permanently on a server or something + +What is a variable? +- A memory location in the RAM +- Do not fly on the Boeing 373 max + +Data types +- Memory management: + - Smallest unit is a bit (0 or 1) + - 1 Byte is 8 bits + - 1024 bytes in 1 kilobyte + - 1024 kilobyte in 1 megabyte + - etc. + +Primitive types (values with a `?` are wrong but Jeg said so) + +| Type | Size | Range | +| ------- | --------- | ------------------------- | +| integer | 4 bytes | integers (-1, 0, 1, etc.) | +| double | 8 bytes | Real numbers | +| float | 4 bytes | Real numbers | +| String | 32 bytes? | all characters | +| Char | 1 byte? | single letter | +| bool | 1 byte | true, false | +| Objects | ~~~ | ~~~ | + diff --git a/content/While Loop.md b/content/While Loop.md new file mode 100644 index 00000000..f5d57261 --- /dev/null +++ b/content/While Loop.md @@ -0,0 +1,2 @@ +Uhhhh uhhhh hhhhhh +Just know they learned these or something like that. \ No newline at end of file diff --git a/content/pain.md b/content/pain.md new file mode 100644 index 00000000..b8a8752e --- /dev/null +++ b/content/pain.md @@ -0,0 +1,14 @@ +# These ones i was braindead +![[Pasted image 20240327144729.png]] +x = 0 +![[Pasted image 20240327144747.png]] + +# These ones i got +x = 0 +![[Pasted image 20240327144918.png]] +Which is is right + + +![[Pasted image 20240327145039.png]] +&&'s cannot be split, but ORs can be +![[Pasted image 20240327145055.png]] diff --git a/content/temp.md b/content/temp.md new file mode 100644 index 00000000..3ec8c4b6 --- /dev/null +++ b/content/temp.md @@ -0,0 +1,32 @@ +Erros: +1. Syntax errors + 1. Will not compile +2. Runtime errors + 1. Program compiles but code during runtime will unexpectedly terminate +3. Logical errors: + 1. Program runs and compiles but the output is wrong + + + +```java +double x = 5 +System.out.println(x); // Will print 5.0; make sure you remember this +``` + +```java +int x = (int)(3.68); +S.o.p(x); // Will print 3 + +``` + +```java +int x = 10; +int y = 20; +x = y; +y = x; + +// X is 20, y is 20 +``` + +> Do the question on google classroom with swapping the two numbers. + diff --git a/package-lock.json b/package-lock.json index 4a8b5833..dbecc832 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "mdast-util-to-hast": "^13.1.0", "mdast-util-to-string": "^4.0.0", "micromorph": "^0.4.5", - "preact": "^10.19.5", + "preact": "^10.22.0", "preact-render-to-string": "^6.3.1", "pretty-bytes": "^6.1.1", "pretty-time": "^1.1.0", @@ -4454,9 +4454,9 @@ } }, "node_modules/preact": { - "version": "10.19.5", - "resolved": "https://registry.npmjs.org/preact/-/preact-10.19.5.tgz", - "integrity": "sha512-OPELkDmSVbKjbFqF9tgvOowiiQ9TmsJljIzXRyNE8nGiis94pwv1siF78rQkAP1Q1738Ce6pellRg/Ns/CtHqQ==", + "version": "10.22.0", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.22.0.tgz", + "integrity": "sha512-RRurnSjJPj4rp5K6XoP45Ui33ncb7e4H7WiOHVpjbkvqvA3U+N8Z6Qbo0AE6leGYBV66n8EhEaFixvIu3SkxFw==", "funding": { "type": "opencollective", "url": "https://opencollective.com/preact" diff --git a/package.json b/package.json index 54c67fbf..80b88a5f 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "mdast-util-to-hast": "^13.1.0", "mdast-util-to-string": "^4.0.0", "micromorph": "^0.4.5", - "preact": "^10.19.5", + "preact": "^10.22.0", "preact-render-to-string": "^6.3.1", "pretty-bytes": "^6.1.1", "pretty-time": "^1.1.0",