Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virologist kódminőségének javítása sonarlint jelzések alapján #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/main/java/virologist/model/Virologist.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -258,8 +260,8 @@ public void Move()
{
if (actionCount > 0) {
ArrayList<Field> fields = field.GetNeighbours();

if (fields.size() != 0) {
if (!fields.isEmpty()) {
Random random = new Random();
Move(fields.get(random.nextInt(fields.size())));
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
Loading