update: fix

This commit is contained in:
Sobottasgithub
2026-01-14 07:04:38 +01:00
parent 6854157edd
commit 74e46e60c7
5 changed files with 88 additions and 14 deletions

View File

@@ -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();
}
}
*/
}

View File

@@ -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();
}

View File

@@ -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);
*/
}
}

View File

@@ -10,15 +10,15 @@ public class Node<T> {
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;
}
}

61
flake.lock generated Normal file
View File

@@ -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
}