From 74e46e60c7130184ab9e316f2c7330aa84b46d43 Mon Sep 17 00:00:00 2001 From: Sobottasgithub Date: Wed, 14 Jan 2026 07:04:38 +0100 Subject: [PATCH] update: fix --- Hero.java | 6 +++-- LinkedList.java | 16 ++++++------- Main.java | 13 ++++++++++- Node.java | 6 ++--- flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 14 deletions(-) create mode 100644 flake.lock diff --git a/Hero.java b/Hero.java index be914ff..67dc784 100644 --- a/Hero.java +++ b/Hero.java @@ -12,7 +12,7 @@ public class Hero { public LinkedList getWeaponInventory() { return weaponInventory; } - + /* public void addWeapon(Weapon weapon) { weaponInventory.append(weapon); } @@ -23,7 +23,9 @@ public class Hero { weaponInventory.toNext(); } if (weaponInventory.hasAccess()) { - currentWeapon = weaponInventory.getCurrentContent(); + System.out.println("Weapon was chosen"); + //currentWeapon = weaponInventory.getCurrentContent(); } } + */ } diff --git a/LinkedList.java b/LinkedList.java index 0d1858e..c1b1112 100644 --- a/LinkedList.java +++ b/LinkedList.java @@ -24,7 +24,7 @@ public class LinkedList { public void toNext() { if (hasAccess()) { - current = current.nextNode(); + current = current.getNextNode(); } } @@ -48,7 +48,7 @@ public class LinkedList { first = newNode; last = newNode; } else { - last.setNext(newNode); + last.setNextNode(newNode); last = newNode; } size++; @@ -71,15 +71,15 @@ public class LinkedList { public void remove() { if (hasAccess()) { - if (head == tail) { - head = null; - tail = null; + if (first == last) { + first = null; + last = null; current = null; return; } Node newCurrent = current.getNextNode(); - Node pointer = head; + Node pointer = first; while(pointer.getNextNode() != current) { pointer = pointer.getNextNode(); } @@ -96,9 +96,9 @@ public class LinkedList { size = weaponList.getSize(); return; } - head = weaponList.getFirst(); + first = weaponList.getFirst(); last = weaponList.getFirst(); - current = head; + current = first; size += weaponList.getSize(); } diff --git a/Main.java b/Main.java index ad59f56..9e88d2e 100644 --- a/Main.java +++ b/Main.java @@ -1,5 +1,16 @@ public class Main { public static void main(String[] args) { - Hero hero = new Hero(); + Weapon weapon1 = new Weapon("dagger", 12); + Weapon weapon2 = new Weapon("sword", 10); + Weapon weapon3 = new Weapon("bow", 1); + + Hero hero = new Hero("held", 12); + /* + hero.addWeapon(weapon1); + hero.addWeapon(weapon2); + hero.addWeapon(weapon3); + + hero.chooseWeapon(weapon3); + */ } } diff --git a/Node.java b/Node.java index f19ca92..fcf602e 100644 --- a/Node.java +++ b/Node.java @@ -10,15 +10,15 @@ public class Node { this.content = content; } - private T getContent() { + public T getContent() { return this.content; } - private void setNextNode(Node nextNode) { + public void setNextNode(Node nextNode) { this.nextNode = nextNode; } - private Node getNextNode() { + public Node getNextNode() { return this.nextNode; } } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..fdd4d88 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1768135262, + "narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1768127708, + "narHash": "sha256-1Sm77VfZh3mU0F5OqKABNLWxOuDeHIlcFjsXeeiPazs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ffbc9f8cbaacfb331b6017d5a5abb21a492c9a38", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +}