Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java - Ants vs Zombies

JamesCaron
JamesCaron 


Because there are many attachments, please follow this link: http://www.csee.umbc.edu/courses/undergraduate/202/fall12/projects/project4/ Attachments Tags Clarifications

Answers

Java - Ants vs Zombies Solution

dickersonka
dickersonka 



Attached is the solution to... Attachments
ZombieGame.zip (16 K) Download







Preview
amount) { life -= amount; } public void takeDamage(int amount, Zombie zombie) { life -= amount; } public String getName(){ return this.name; } public int getFoodCost(){ return this.foodCost; }

Preview
Zombie { public ArmoredZombie() { super(20, 15, "Armored Zombie"); firstHit = true; } public

Preview
public ArmyAnt() { super(35, 30, "Army Ant"); NUM_RECRUITED++; } @Override public void

Preview
@Override public void attack(Game game) { Zombie zombie = game.getHorde().elementAt(0);

Preview
game.getHorde().elementAt(0); zombie.takeDamage(10); } @Override Ant newAnt() { return new

Preview
public class CitronellaAnt extends Ant{ public CitronellaAnt() { super(25, 20, "Citronella Ant");

Preview
Flammable){ zombie.takeDamage(20); } else { zombie.takeDamage(10); } } @Override Ant newAnt()

Preview
proj4; public

Preview
the ants and reset their life Iterator<Ant> iterator = this.colony.iterator(); while (iterator.hasNext()){ Ant ant = iterator.next(); ant.resetLife(); } //increment round this.roundNumber += 1; } return roundOver; } @Override public String getEndingMessage() { if (this.gameOver) return "Game over"; return "You win - Final Score: " + this.food + "."; }

Preview
order, and has newlines separating * zombies. * @return Multiline description of horde. */ public String getHordeDesc(); /** * Execute a fight between the first ant in the colony and first * zombie in the horde. */ public void nextFight(); /** * Determine if the invasion is over. If the

Preview
{ public GiantZombie() { super(40, 20, "Giant Zombie");

Preview
package

Preview
implements Flammable { public InfectedZombie() { super(20, 15,

Preview
p.add(roundNum, c); JLabel foodLabel = new JLabel("Food: ", SwingConstants.RIGHT); foodLabel.setFont(new Font("SansSerif", Font.PLAIN, 16)); c.gridx = 2; c.anchor = GridBagConstraints.EAST; p.add(foodLabel, c); foodNum = new JLabel("" + game.getFood(), SwingConstants.LEFT); foodNum.setFont(new Font("SansSerif", Font.PLAIN, 16)); c.gridx = 3; c.anchor = GridBagConstraints.WEST; p.add(foodNum, c); colony = new JTextArea(10, 20); colony.setEditable(false); colony.setText(game.getCol

Preview
= game.getHorde().elementAt(0); zombie.takeDamage(10); } @Override Ant newAnt() { return

Preview
public class PharaohAnt extends Ant{ public PharaohAnt() { super(15, 10, "Pharaoh Ant"); } @Override

Preview
DO NOT submit this file. * */ package proj4; import java.io.*; import javax.swing.*; public class Project4 { public static void main(String args[]) { GameInterface game = new Game(); File f = new File("."); String

Preview
{ super(70, 25, "Radioactive Zombie"); } public void attack(Game g) { Ant

Preview
title.setForeground(Color.BLUE); add(title, BorderLayout.NORTH); JPanel p = new JPanel(new GridBagLayout()); add(p, BorderLayout.CENTER); GridBagConstraints c = new GridBagConstraints(); JLabel roundLabel = new JLabel("Round: ", SwingConstants.RIGHT); roundLabel.setFont(new Font("SansSerif", Font.PLAIN, 16)); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 0; c.ipadx = 4; c.ipady = 20; c.anchor = GridBagConstraints.EAST; p.add(roundLabel, c);

Preview
10, "Standard Zombie"); } public void attack(Game g)

Preview
attack(Game game) { Zombie zombie = game.getHorde().elementAt(0); zombie.takeDamage(10); if(zombie.getLife() <= 0){ game.addFood(5); }

Preview
@Override public void attack(Game game) { } @Override public void takeDamage(int amount,

Preview
{ Ant a = g.getColony().elementAt(0); a.takeDamage(10, this); if (a.getLife() <=

Preview
> 1){ Zombie zombie = game.getHorde().elementAt(1); zombie.takeDamage(15); } } @Override Ant newAnt()

Preview
= life; this.reward = reward; this.desc = desc; } public static Zombie makeZombie(char c) { switch (c) { case 'A': return new ArmoredZombie(); case 'G': return new GiantZombie(); case 'I': return new InfectedZombie(); case 'R': return

Preview
package proj4; public class ZombieNinja extends Zombie { public

Preview
package proj4; public class ZombieScientist extends Zombie { public

Screenshots
Purchase Answer