Skip to content
Open
Show file tree
Hide file tree
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
47 changes: 8 additions & 39 deletions src/OOAD/Ants.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,12 @@
package OOAD;

public class Ants extends Organism {
private boolean newBreed = false;
private boolean moved = false;
private Location location = new Location();

Ants(String name){
super(name);
public boolean newBreed = false;
public boolean moved = false;
Ants(){
super.name = "Ants";
}

public boolean isNewBreed() {
return newBreed;
}

public void setNewBreed(boolean newBreed) {
this.newBreed = newBreed;
}

public boolean isMoved() {
return moved;
}

public void setMoved(boolean moved) {
this.moved = moved;
}

public Location getLocation() {
return location;
}

public void setLocation(Location location) {
this.location = location;
}

@Override
public boolean checkMovement(int current_x, int current_y, int next_x, int next_y) {
if((current_x - next_x == 1 || current_x - next_x == -1) && current_y - next_y == 0 && next_x < 20 && next_x >= 0&& next_y < 20 && next_y >= 0) {
Expand All @@ -47,24 +21,19 @@ else if(current_x - next_x == 0 && (current_y - next_y == 1 || current_y - next_
@Override
public Location checkBreed(int current_x, int current_y, Organism[][] backBoard) {
if ((current_y - 1) > 0 && backBoard[current_x][current_y - 1] == null ){
System.out.println("Breed Up");
return new Location(current_x,current_y-1);
}
else if ((current_y + 1) < 20 && backBoard[current_x][current_y + 1] == null){
System.out.println("Breed Down");
return new Location(current_x,current_y+1);
return new Location(current_x,current_y+1);
}
else if ((current_x + 1) < 20 && backBoard[current_x + 1][current_y] == null ){
System.out.println("Breed Right");
return new Location(current_x+1,current_y);
return new Location(current_x+1,current_y);
}
else if ((current_x - 1 )> 0 && backBoard [current_x-1][current_y] == null ){
System.out.println("Breed Left");
return new Location(current_x-1,current_y);
return new Location(current_x-1,current_y);
}
else
System.out.println("No breed");
return null;
return null;
}

@Override
Expand Down
82 changes: 21 additions & 61 deletions src/OOAD/Bugs.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,16 @@

public class Bugs extends Organism {
//parameter
private boolean newBreed = false;
private boolean moved = false;
private int starveRound = 0;
private int antsKill = 0 ;
private Location location = new Location();

public Location getLocation() {
return location;
}

public void setLocation(Location location) {
this.location = location;
}

Bugs(String name){
super(name);
public boolean newBreed = false;
public boolean moved = false;
public int starveRound = 0;
Bugs(){
super.name = "Bugs";
}

public boolean isNewBreed() {
return newBreed;
}

public void setNewBreed(boolean newBreed) {
this.newBreed = newBreed;
}

public boolean isMoved() {
return moved;
}

public void setMoved(boolean moved) {
this.moved = moved;
}

public int getAntsKill() {
return antsKill;
}

public void plusAntsKill() {
this.antsKill++;
}

public int getStarveRound() {
return starveRound;
}

public void plusStarveRound() {
this.starveRound++;
}

public void reserStarveRound() {
this.starveRound = 0;
}

public void resetMoved(){
moved = false;
}
@Override
public boolean checkMovement(int current_x, int current_y, int next_x, int next_y) {
if((current_x - next_x == 1 || current_x - next_x == -1) && current_y - next_y == 0 && next_x < 20 && next_x >= 0&& next_y < 20 && next_y >= 0) {
Expand All @@ -70,27 +26,31 @@ else if(current_x - next_x == 0 && (current_y - next_y == 1 || current_y - next_
@Override
public Location checkBreed(int current_x, int current_y, Organism[][] backBoard) {
if ((current_y - 1) > 0 && backBoard[current_x][current_y - 1] == null ){
System.out.println("Breed Up");
return new Location(current_x,current_y-1);
}
else if ((current_y + 1) < 20 && backBoard[current_x][current_y + 1] == null){
System.out.println("Breed Down");
return new Location(current_x,current_y+1);
return new Location(current_x,current_y+1);
}
else if ((current_x + 1) < 20 && backBoard[current_x + 1][current_y] == null ){
System.out.println("Breed Right");
return new Location(current_x+1,current_y);
return new Location(current_x+1,current_y);
}
else if ((current_x - 1 )> 0 && backBoard [current_x-1][current_y] == null ){
System.out.println("Breed Left");
return new Location(current_x-1,current_y);
return new Location(current_x-1,current_y);
}
else
System.out.println("No breed");
return null;
return null;
}



public boolean isStarving() {
if(starveRound == 3){
return true;
}
else
return false;
}

/*
public static void main(String[] args){
Bugs bugs = new Bugs();
Expand Down
4 changes: 2 additions & 2 deletions src/OOAD/Connector.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class Connector {

private GUI gui = new GUI();
private NewGame game = new NewGame();
private Game game = new Game();
private ImageIcon ant = ant();
private ImageIcon bug = bug();
private ImageIcon ant(){
Expand Down Expand Up @@ -43,7 +43,7 @@ private ImageIcon bug(){
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("first row in start button actionlistener");
game = new NewGame();
game = new Game();
gui.counter = 0;
gui.counter++;
gui.startBtn.setEnabled(false);
Expand Down
Loading