Skip to content

Commit

Permalink
Merge pull request #15 from BME-MIT-IET/sonarcloud-issues-fix
Browse files Browse the repository at this point in the history
Sonarcloud main issues fix
  • Loading branch information
Duhi95 authored May 22, 2024
2 parents 5bfcb9d + dbc59de commit e243b95
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 269 deletions.
95 changes: 39 additions & 56 deletions src/main/java/ActionButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/
public class ActionButton extends JButton{
private ArrayList<Integer> actions;
//private Element element;

ActionButton(ArrayList<Integer> acts/*Element _element*/)
{
Expand All @@ -23,67 +22,51 @@ public class ActionButton extends JButton{
actions.add(0);
actions.add(0);

//element=_element;
/** Ezen keresztul tudjuk meghivni a Control fuggvenyeit.*/
Control instance = Control.getInstance();

addActionListener(
new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e) {
Game.getInstance().getCurrentCharacter().decreaseRemainingSteps();
switch(e.getActionCommand()) {
case "Move":
/** Atadja a kivalasztott Elementet amire lepni szeretne.*/
instance.Move(actions.get(0));
break;
/** Valasztott Elementen lyukasztas.*/
case "Stab":
instance.Stab();
break;
/** Valasztott Elementen pumpa elhelyezes.*/
case "PlacePump":
instance.PlacePump();
break;
/** Valasztott Elementen cso elhelyezes.*/
case "PlacePipe":
instance.PlacePipe();
break;
/** Valasztott cso vegenek felvetele.*/
case "PickupPump":
instance.PickupPump();
break;
/** Valasztott cso vegenek felvetele.*/
case "PickUpPipe":
instance.PickUpPipe(actions.get(0));
break;
/** Valasztott Element javitasa.*/
case "Repair":
instance.Repair();
break;
/** Valasztott Element ragadossa tetele.*/
case "Stick":
instance.Stick();
break;
/** Valasztott Element csuszossa tetele.*/
case "Slime":
instance.Slime();
break;
/** Pumpa ki es bemenetenek allitasa.*/
case "Adjust":
//ez meg kerdeses


addActionListener(e -> {
Game.getInstance().getCurrentCharacter().decreaseRemainingSteps();
switch(e.getActionCommand()) {
case "Move":
instance.Move(actions.get(0));
break;
case "Stab":
instance.Stab();
break;
case "PlacePump":
instance.PlacePump();
break;
case "PlacePipe":
instance.PlacePipe();
break;
case "PickupPump":
instance.PickupPump();
break;
case "PickUpPipe":
instance.PickUpPipe(actions.get(0));
break;
case "Repair":
instance.Repair();
break;
case "Stick":
instance.Stick();
break;
case "Slime":
instance.Slime();
break;
case "Adjust":
instance.Adjust(actions.get(0), actions.get(1));
break;
/** Adott karakter korenek vege.*/
case "EndMove":
instance.EndMove();
break;
break;
case "EndMove":
instance.EndMove();
break;
default:
break;
}
}


}
});
}
}
12 changes: 0 additions & 12 deletions src/main/java/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ void setName(String name) {
@Override
public void adjust(int src, int dest) {
Control.getInstance().appendToLog(this.Name+" is not adjustable.");
//System.out.println(this.Name+" is not adjustable.");
}


Expand All @@ -95,7 +94,6 @@ public void adjust(int src, int dest) {
public boolean accept(Character c) {
standingOn.add(c);
Control.getInstance().appendToLog("Successfully moved to "+ this.getName());
// System.out.println("Successfully moved to "+ this.getName());
return true;
}

Expand All @@ -115,7 +113,6 @@ public boolean remove(Character c) {
@Override
public void damage() {
Control.getInstance().appendToLog(this.Name+" is undamageable!");
//System.out.println("Ilyen elemet nem lehet kilyukasztani!");
}

/**
Expand All @@ -124,7 +121,6 @@ public void damage() {
@Override
public void repair() {
Control.getInstance().appendToLog(this.Name+"is unrepairable");
//System.out.println(this.Name+" unrepairable");
}


Expand All @@ -135,7 +131,6 @@ public void repair() {
@Override
public Pump givePump() {
Control.getInstance().appendToLog("Can't pick up Pump here");
//System.out.println("Can't pick up Pump here");
return null;
}

Expand All @@ -148,7 +143,6 @@ public Pump givePump() {
@Override
public boolean placePipe(Pipe p) {
Control.getInstance().appendToLog("Can't place"+p.getName()+" on "+this.Name);
//System.out.println("Can't place"+p.getName()+" on "+this.Name);
return false;
}

Expand All @@ -160,18 +154,15 @@ public boolean placePipe(Pipe p) {
@Override
public Pipe placePump(Pump p) {
Control.getInstance().appendToLog("Can't place"+p.getName()+" on "+this.Name);
//System.out.println("Can't place"+p.getName()+" on "+this.Name);
return null;
}

public void stick() {
Control.getInstance().appendToLog(this.Name+" can't be sticky");
// System.out.println(this.Name+" can't be sticky");
}

public void slime() {
Control.getInstance().appendToLog(this.Name+" can't be slimey");
// System.out.println(this.Name+" can't be slimey");
}

/**
Expand All @@ -185,17 +176,14 @@ public Pipe lift(int dir) {
this.getNeighbors().remove(dir);
n.removeNeighbor((NonPipe) this); // n. removeNeighbor(onmaga)?
Control.getInstance().appendToLog("Successfully picked up " + n.getName());
// System.out.println("Successfully picked up "+n.getName());
return n;
}else {
Control.getInstance().appendToLog("Invalid object to pick up");
// System.out.println("Invalid object to pick up");
return null;
}
}catch(IndexOutOfBoundsException e) {
//ha ervenytelen az index
Control.getInstance().appendToLog("Invalid object to pick up");
// System.out.println("Invalid object to pick up");
return null;
}

Expand Down
Loading

0 comments on commit e243b95

Please sign in to comment.