From 11756e931638f020f13400f93f2e5790d523fac5 Mon Sep 17 00:00:00 2001 From: Tamassch <100317312+Tamassch@users.noreply.github.com> Date: Wed, 22 May 2024 17:32:54 +0200 Subject: [PATCH] =?UTF-8?q?Virologist=20k=C3=B3dmin=C5=91s=C3=A9g=C3=A9nek?= =?UTF-8?q?=20jav=C3=ADt=C3=A1sa=20sonarlint=20jelz=C3=A9sek=20alapj=C3=A1?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/virologist/model/Virologist.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/virologist/model/Virologist.java b/src/main/java/virologist/model/Virologist.java index 7680a82..e33f253 100644 --- a/src/main/java/virologist/model/Virologist.java +++ b/src/main/java/virologist/model/Virologist.java @@ -16,6 +16,8 @@ import java.util.LinkedList; import java.util.Random; +import javax.management.InvalidAttributeValueException; + /** * A virologusert felelo osztaly. Ezeket az objektumokat * fogjak tudni iranyitani a jatekosok a jatek soran es @@ -258,8 +260,8 @@ public void Move() { if (actionCount > 0) { ArrayList fields = field.GetNeighbours(); - - if (fields.size() != 0) { + + if (!fields.isEmpty()) { Random random = new Random(); Move(fields.get(random.nextInt(fields.size()))); } @@ -423,7 +425,7 @@ public void AddEquipment(Equipment e) */ public Equipment GetEquipment() throws IndexOutOfBoundsException { - if (equipments.size() == 0) + if (equipments.isEmpty()) throw new IndexOutOfBoundsException("ures a felszereles tarolo"); return equipments.remove(equipments.size()-1); @@ -495,7 +497,7 @@ public void StealNukleotid(Virologist self) */ public void StealEquipment(Virologist self) { - if (equipments.size() > 0) { + if (!equipments.isEmpty()) { if(game.randOn) { Random random = new Random(); int r = random.nextInt(equipments.size()); @@ -578,10 +580,10 @@ public void AddNucleotide(int delta) * @param delta a mennyiseg amivel csokkentunk * @throws Exception ha nincs megfelelo mennyiseg akkor kivetelt dobunk */ - public void RemoveNucleotide(int delta) throws Exception + public void RemoveNucleotide(int delta) throws InvalidAttributeValueException { if(delta > nucleotide){ - throw new Exception("I don't have such many nucleotide!"); + throw new InvalidAttributeValueException("I don't have such many nucleotide!"); } nucleotide -= delta; } @@ -591,10 +593,10 @@ public void RemoveNucleotide(int delta) throws Exception * @param delta a mennyiseg amivel csokkentunk * @throws Exception ha nincs megfelelo mennyiseg akkor kivetelt dobunk */ - public void RemoveAminoAcid(int delta) throws Exception + public void RemoveAminoAcid(int delta) throws InvalidAttributeValueException { if(delta > aminoAcid){ - throw new Exception("I don't have such many amino acid!"); + throw new InvalidAttributeValueException("I don't have such many amino acid!"); } aminoAcid -= delta; }