commit 48adeec6381cc7bea5a2612ca4ecc3c0293dc607
parent b80652d7f41199b3138b6fb95515245786d9fa44
Author: thing1 <thing1@seacrossedlovers.xyz>
Date: Mon, 23 Feb 2026 15:46:53 +0000
lecture
.w
w
q
w
q
Diffstat:
12 files changed, 213 insertions(+), 25 deletions(-)
diff --git a/CS10120/20.02.26.md b/CS10120/20.02.26.md
@@ -0,0 +1,5 @@
+# 20/02/26
+
+- its GIF not GIF
+
+- Dracula, gruvbox, and cappatino are nice palets
diff --git a/CS10720/17.02.26.md b/CS10720/17.02.26.md
@@ -0,0 +1,12 @@
+# 17/02/26
+
+## floats
+
+- significand = mantissa
+- written as `-1 ^ sign * mantissa * 10 ^ e`
+ - `12.34 = (-1)^0 * 1.234 * (10 ^ 1)`
+- 0 can't be be written with this, as the mantissa must be at least 1 (lower than 10)
+
+- for binary, we use `-1 ^ sign * mantissa * 2 ^ e`
+ - where 1 <= m < 2
+
diff --git a/CS10720/23.02.26.md b/CS10720/23.02.26.md
@@ -0,0 +1,37 @@
+# 23/02/26
+
+## matrices and arrays
+
+- a group of rows and columns, the number of rows is m, and columns is n
+ - the size of the matrix is written as (m x n), (rows, columns)
+
+- a single row matrix is called a row vector
+- a single column matrix is called a column vector
+- matrix index from 1
+- a matrix that looks like this, is the identity matrix
+```
+(1 0 0)
+(0 1 0)
+(0 0 1)
+```
+this can be any size, just needs to follow this shape (line from top left to bottom right
+
+- you can only add matrices when they are the same size
+ - just add the elements from the same position into the new one
+ ```
+(a+b c+d ....)
+(............)
+ ```
+- subtraction is the same as addition
+
+- you can multiply matrices by numbers or other matrices
+- we use the `.` to multiply not `x` or `*`
+
+- when multiplying by a number, just multiply each element by the number
+
+- when multiplying by another matrix
+ - the number of columns must be the same as the number of rows in the second matrix
+ - `{(n _ 1 == m _ 2)}`
+ - its not commutative operation (a * b != b * a)
+ - a 3 x 5 matrix can be multiplied by a 5 x 10 (the second number of the first matrix, needs to be the same as the first number of the second matrix)
+ - you multiply rows, by columns, the value at (2, 4) is the sum of the products from row 2 in matrix 1 and column 4 in matrix 2
diff --git a/CS12320/tutorial/Main.java b/CS12320/tutorial/Main.java
@@ -0,0 +1,40 @@
+import java.util.Scanner;
+
+public class Main {
+ private static String msgs[] = {
+ "set the Time",
+ "set the Alarm time",
+ "quit"
+ };
+ private static String keys[] = {
+ "S",
+ "A",
+ "q"
+ };
+
+ private static void printMenu() {
+ System.out.println("What do you want to do?");
+ for (int i = 0; i < msgs.length; i++)
+ System.out.println(keys[i] + " - " + msgs[i]);
+ }
+
+ private static void runMenu() {
+ Scanner sc = new Scanner(System.in);
+ while (true) {
+ printMenu();
+ String in = sc.nextLine();
+
+
+ switch (in.charAt(0)) {
+ case 'q': return;
+ case 'S': System.out.println("Set time"); break;
+ case 'A': System.out.println("Set alarm time"); break;
+ default: System.out.println("Invalid menu item " + in); break;
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ runMenu();
+ }
+}
diff --git a/CS12320/workshop/5/out/production/5/Monster/Main.class b/CS12320/workshop/5/out/production/5/Monster/Main.class
Binary files differ.
diff --git a/CS12320/workshop/5/out/production/5/Monster/Monster.class b/CS12320/workshop/5/out/production/5/Monster/Monster.class
Binary files differ.
diff --git a/CS12320/workshop/5/out/production/5/Monster/MonsterType.class b/CS12320/workshop/5/out/production/5/Monster/MonsterType.class
Binary files differ.
diff --git a/CS12320/workshop/5/out/production/5/Monster/Player.class b/CS12320/workshop/5/out/production/5/Monster/Player.class
Binary files differ.
diff --git a/CS12320/workshop/5/src/Monster/Main.java b/CS12320/workshop/5/src/Monster/Main.java
@@ -7,31 +7,31 @@ public class Main {
/**
* The entry method to the program
*/
- public static void main(String[] args) {
- Monster orc = new Monster(MonsterType.HUMANOID,"Black",true);
- Monster sage = new Monster(MonsterType.WIZARD, "White", false);
- Monster goblin = new Monster(MonsterType.HUMANOID, null,true );
+ public static void main(String[] args) throws InterruptedException{
+ Weapon sword = new Weapon(WeaponType.SWORD, 6);
+ Player player = new Player(6, sword, "Hero");
- Treasure coin1 = new Treasure(TreasureType.COIN, "Golden",50);
- Treasure coin2 = new Treasure(TreasureType.COIN, "Silver",20);
- Treasure coin3 = new Treasure(TreasureType.COIN, "Iron",15);
- Treasure healing = new Treasure(TreasureType.POTION, "Yellow",40);
- Treasure growth = new Treasure(TreasureType.POTION, "Red",10);
- Treasure ruby = new Treasure(TreasureType.GEM, "Red",60);
- Treasure emerald = new Treasure(TreasureType.GEM, "Green",40);
- Treasure amber = new Treasure(TreasureType.GEM, "Yellow",30);
+ Room greathall = new Room("Great Hall");
+ Room crypt = new Room("Crypt", null, null, null, greathall);
+ greathall.setEast(crypt);
+ Room park = new Room("Park", crypt, null, null, null);
+ crypt.setSouth(park);
- Weapon exalibur = new Weapon(WeaponType.SWORD, 100);
+ player.setRoom(greathall);
+ if (player.moveEast() == null)
+ System.out.println("couldnt move, no room East");
+ else
+ System.out.println(player.getRoom().getName());
- orc.addTreasure(coin1);
- orc.addTreasure(coin2);
- orc.addTreasure(coin3);
- orc.addTreasure(healing);
- orc.addTreasure(growth);
- orc.calculateHealthPoints();
+ if (player.moveWest() == null)
+ System.out.println("couldnt move, no room West");
+ else
+ System.out.println(player.getRoom().getName());
- orc.setWeapon(exalibur);
+ if (player.moveWest() == null)
+ System.out.println("couldnt move, no room West");
+ else
+ System.out.println(player.getRoom().getName());
- System.out.println(orc.toString());
}
}
diff --git a/CS12320/workshop/5/src/Monster/Monster.java b/CS12320/workshop/5/src/Monster/Monster.java
@@ -6,8 +6,9 @@ package Monster;
enum MonsterType {
HUMANOID,
WIZARD,
- GIANT
-}
+ GIANT,
+ GOBLIN,
+};
/**
* A big scary monster class
@@ -22,7 +23,6 @@ public class Monster {
private int numTreasure;
private Weapon weapon;
-
/**
* The maximum ammount of Treasure a monster can hold
*/
@@ -39,6 +39,8 @@ public class Monster {
this.hairColor = hairColor;
this.isHostile = isHostile;
this.ownsTreasure = new Treasure[MAX_TREASURE];
+ this.weapon = new Weapon(WeaponType.STICK, 1);
+ this.healthPoints = 20;
}
/**
@@ -110,6 +112,7 @@ public class Monster {
this.ownsTreasure[this.numTreasure] = item;
this.numTreasure++;
} else System.err.println("To much treasure!");
+ this.calculateHealthPoints();
}
public int getNumTreasure() {
@@ -134,7 +137,7 @@ public class Monster {
/**
* Sets the health of the monster based on the weapons the monster has
*/
- public void calculateHealthPoints() {
+ private void calculateHealthPoints() {
this.healthPoints = 0;
for (Treasure t : this.ownsTreasure) {
this.healthPoints += t.getPowerPoints();
@@ -148,4 +151,9 @@ public class Monster {
public void setWeapon(Weapon weapon) {
this.weapon = weapon;
}
+
+ public int attack(Player p) {
+ int playerHealth = p.getHealthPoints() - this.weapon.getDamagePoints();
+ return (playerHealth < 0) ? 0 : playerHealth;
+ }
}
diff --git a/CS12320/workshop/5/src/Monster/Player.java b/CS12320/workshop/5/src/Monster/Player.java
@@ -0,0 +1,58 @@
+package Monster;
+
+public class Player {
+ private int healthPoints;
+ private Weapon weapon;
+ private Treasure treasure[];
+ private int treasureCount;
+ private String name;
+ private Room room;
+
+ public final int MAXTREASURE = 10;
+
+ public Player(int healthPoints, Weapon weapon, String name) {
+ this.healthPoints = healthPoints;
+ this.weapon = weapon;
+ this.treasure = new Treasure[MAXTREASURE];
+ this.treasureCount = 0;
+ this.name = name;
+ }
+
+ public void setWeapon(Weapon weapon) { this.weapon = weapon; }
+
+ public void setRoom(Room room) { this.room = room; }
+ public Room getRoom() { return this.room; }
+ public Room moveNorth() { return (this.room = (this.room.getNorth() != null) ? this.room.getNorth() : null); }
+ public Room moveSouth() { return (this.room = (this.room.getSouth() != null) ? this.room.getSouth() : null); }
+ public Room moveEast() { return (this.room = (this.room.getEast() != null) ? this.room.getEast() : null); }
+ public Room moveWest() { return (this.room = (this.room.getWest() != null) ? this.room.getWest() : null); }
+
+ private boolean addtreasure(Treasure t) {
+ if (this.treasureCount < this.MAXTREASURE) this.treasure[this.treasureCount] = t;
+ else return false;
+ return true;
+ }
+
+ public int getHealthPoints() { return this.healthPoints; }
+
+ public void setHealthPoints(int healthPoints) { this.healthPoints = healthPoints; }
+
+ public int attack(Monster m) {
+ int monsterHealth = m.getHealthPoints() - this.weapon.getDamagePoints();
+ if (monsterHealth < 0) {
+ for (Treasure t : m.getOwnedTreasure()) {
+ if (!addtreasure(t)) {
+ System.out.println("The players pockets are full, you leave the treasure");
+ break;
+ }
+ }
+ } else return monsterHealth;
+
+ return 0;
+ }
+
+ public String toString() {
+ return "Player called " + this.name +
+ " with health " + this.healthPoints;
+ }
+}
diff --git a/CS12320/workshop/5/src/Monster/Room.java b/CS12320/workshop/5/src/Monster/Room.java
@@ -0,0 +1,28 @@
+package Monster;
+
+public class Room {
+ private String name;
+ private Room north, south, east, west;
+
+ public Room(String name) { this.name = name; }
+
+ public Room(String name, Room north, Room south, Room east, Room west) {
+ this.name = name;
+ this.north = north;
+ this.south = south;
+ this.east = east;
+ this.west = west;
+ }
+
+ public void setNorth(Room north) { this.north = north; }
+ public void setSouth(Room south) { this.south = south; }
+ public void setEast(Room east) { this.east = east; }
+ public void setWest(Room west) { this.west = west; }
+
+ public Room getNorth() { return this.north; }
+ public Room getSouth() { return this.south; }
+ public Room getEast() { return this.east; }
+ public Room getWest() { return this.west; }
+
+ public String getName() { return this.name; }
+};