Skip to content

Commit

Permalink
Copy files to other folder for merge
Browse files Browse the repository at this point in the history
  • Loading branch information
LaciProg committed May 21, 2024
1 parent 64955c1 commit a92a3fe
Show file tree
Hide file tree
Showing 16 changed files with 212 additions and 231 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
package Controll;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Color;
import javax.swing.WindowConstants;

import java.io.FileNotFoundException;

import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JComboBox;


public class Menu extends JFrame implements ActionListener {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package Controll;

import Drawing.*;
import Drawing.Drawable;
import Drawing.PipeDraw;
import Enums.Fluid;
import Fields.*;

import Fields.ActiveFields.*;
import Fields.Pipe;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.WindowConstants;

public class ViewGame extends JFrame implements ActionListener {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package Drawing;

import Controll.ViewGame;

import javax.swing.*;
import java.awt.*;

Expand Down Expand Up @@ -31,6 +32,7 @@ public CisternDraw(int tmpX, int tmpY) {
* @param panel
* @param g
*/
@Override
public void Draw(JPanel panel, Graphics2D g) {
cistern.setBounds(x, y, 50, 50);
cistern.setBorder(BorderFactory.createLineBorder(Color.blue, 5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ public PipeDraw(int x1, int y1, int x2, int y2) {
pipeB.addActionListener(ViewGame.selectListener);
}
public void setCoords(Drawable pumpFrom, Drawable pumpTo) {
int fromX, toX, fromY, toY;

int fromX;
int toX;
int fromY;
int toY;

fromX = pumpFrom.getX();
fromY = pumpFrom.getY();
toX = pumpTo.getX();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public PumpDraw(int tmpX, int tmpY) {
* @param panel The panel to draw on.
* @param g The graphics to draw with.
* */
@Override
public void Draw(JPanel panel, Graphics2D g) {
pump.setBounds(x, y, 50, 50);
Pump p = (Pump)ViewGame.objectDrawNames.get(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Fields.Pipe;
import Players.Player;
import Players.Saboteur;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package Drawing;

import Controll.ViewGame;

import javax.swing.*;
import java.awt.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public abstract class ActiveFields extends Field {
* @return The pipes connected to the active field
*/
public ArrayList<Pipe> getPipes() {
if (pipes.size() == 0) return null;
if (pipes.isEmpty()) return new ArrayList<>();
return pipes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import Controll.Controller;
import Fields.Pipe;
import Players.Player;
import StringResource.StringResourceController;

import java.util.ArrayList;
import java.util.Random;

Expand Down Expand Up @@ -30,7 +32,7 @@ public Cistern() {
*/
@Override
public void step() {
if (getPipes() != null) {
if (!getPipes().isEmpty()) {
for (Pipe pipe : getPipes()) {
super.setWater(super.getWater() + pipe.getWater());
}
Expand Down Expand Up @@ -59,16 +61,6 @@ public Pump createNewPump(boolean b) {
else return null;
}

/**
* Method for getting the water from the field.
* Prints the amount of water taken.
* @return The amount of water in the field.
*/
@Override
public int getWater() {
return super.getWater();
}

/**
* Method for picking up a (new) pipe from the field.
* @return The new pipe.
Expand All @@ -92,35 +84,16 @@ public Pipe pickUpPipe() {
@Override
public String toString() {
ArrayList<Player> players = this.getPlayers();
String playersNames = "null";

for (int i = 0; i < players.size(); i++) {
if(i == 0) playersNames = "";
playersNames += Controller.objectReverseNames.get(players.get(i));
if (i != players.size() - 1) {
playersNames += ", ";
}
}


String playerBuilder = StringResourceController.stingBuilder(players);

ArrayList<Pipe> pipes = this.getPipes();
String pipesNames ="null";
if(pipes != null) {
for (int i = 0; i < pipes.size(); i++) {
if (i == 0) pipesNames = "";
pipesNames += Controller.objectReverseNames.get(pipes.get(i));
if (i != pipes.size() - 1) {
pipesNames += ", ";
}
}
}
String pipeBuilder = StringResourceController.stingBuilder(pipes);

return "name: "+ Controller.objectReverseNames.get(this)
+ "\noccupied: " + this.isOccupied()
+ "\nwater: " + getWaterNoChange()
+ "\nbroken: " + this.isBroken()
+ "\nplayers: " + playersNames
+ "\npipes: " + pipesNames + "\n";
+ "\nplayers: " + playerBuilder
+ "\npipes: " + pipeBuilder + "\n";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Controll.Controller;
import Fields.Pipe;
import Players.Player;
import StringResource.StringResourceController;

import java.util.ArrayList;
import java.util.Random;
Expand Down Expand Up @@ -128,19 +129,17 @@ public String toString() {

String playersNames = getPlayerNames();



String pipesNames = getPipeNames();


String SWaterFrom="";
String SWaterTo="";
String sWaterFrom="";
String sWaterTo="";
if(getWaterFrom() == -1 && getWaterTo() == -1 ){
SWaterFrom = SWaterTo = "null";
sWaterFrom = sWaterTo = "null";
}
else{
SWaterFrom = ""+Controller.objectReverseNames.get(getPipes().get(getWaterFrom()));
SWaterTo = ""+Controller.objectReverseNames.get(getPipes().get(getWaterTo()));
sWaterFrom = ""+Controller.objectReverseNames.get(getPipes().get(getWaterFrom()));
sWaterTo = ""+Controller.objectReverseNames.get(getPipes().get(getWaterTo()));
}


Expand All @@ -151,36 +150,18 @@ public String toString() {
+ "\nplayers: " + playersNames
+ "\npipes: " + pipesNames
+ "\ntank: " + this.getTank()
+ "\nwaterFrom: " +SWaterFrom
+ "\nwaterTo: " +SWaterTo + "\n";
+ "\nwaterFrom: " +sWaterFrom
+ "\nwaterTo: " +sWaterTo + "\n";
}

private String getPlayerNames() {
ArrayList<Player> players = this.getPlayers();
String playersNames = "null";
for (int i = 0; i < players.size(); i++) {
if(i == 0) playersNames = "";
playersNames += Controller.objectReverseNames.get(players.get(i));
if (i != players.size() - 1) {
playersNames += ", ";
}
}
return playersNames;
return StringResourceController.stingBuilder(players);
}


private String getPipeNames(){
ArrayList<Pipe> pipes = this.getPipes();
String pipesNames ="null";
if(pipes != null) {
for (int i = 0; i < pipes.size(); i++) {
if (i == 0) pipesNames = "";
pipesNames += Controller.objectReverseNames.get(pipes.get(i));
if (i != pipes.size() - 1) {
pipesNames += ", ";
}
}
}
return pipesNames;
return StringResourceController.stingBuilder(pipes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Controll.Controller;
import Fields.Pipe;
import Players.Player;
import StringResource.StringResourceController;

import java.util.ArrayList;

Expand Down Expand Up @@ -60,32 +61,18 @@ public void step() {
@Override
public String toString() {
ArrayList<Player> players = this.getPlayers();
String playerBuilder = StringResourceController.stingBuilder(players);

String playersNames = "null";

for (int i = 0; i < players.size(); i++) {
if(i == 0) playersNames = "";
playersNames += Controller.objectReverseNames.get(players.get(i));
if (i != players.size() - 1) {
playersNames += ", ";
}
}

ArrayList<Pipe> pipes = this.getPipes();
String pipesNames ="null";
for (int i = 0; i < pipes.size(); i++) {
if(i == 0) pipesNames = "";
pipesNames += Controller.objectReverseNames.get(pipes.get(i));
if (i != pipes.size() - 1) {
pipesNames += ", ";
}
}
String pipeBuilder = StringResourceController.stingBuilder(pipes);

return "name: "+ Controller.objectReverseNames.get(this)
+ "\noccupied: " + this.isOccupied()
+ "\nwater: " + getWaterNoChange()
+ "\nbroken: " + this.isBroken()
+ "\nplayers: " + playersNames
+ "\npipes: " + pipesNames
+ "\nplayers: " + playerBuilder
+ "\npipes: " + pipeBuilder
+ "\nwaterOut: " + this.getWaterOut()
+ "\nmaxOutWater: " + this.getMaxOutWater() + "\n";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import Fields.ActiveFields.Pump;
import Interfaces.Steppable;
import Players.Player;

import java.util.ArrayList;

/**
Expand Down
Loading

0 comments on commit a92a3fe

Please sign in to comment.