Code:
import java.awt.*;
import java.awt.event.* ;
import java.awt.image.*;
import java.awt.geom.* ;
import javax.swing.* ;
import javax.swing.event.* ;
public class NPCObject {
public void NPCObject(int strength, int defense, boolean attackable, String imageFile, int x, int y) {
int objStrength = strength;
int objDefense = defense;
boolean objAttackable = attackable;
int xLoc = x;
int yLoc = y;
BufferedImage objIcon = loadImage(imageFile);
public boolean canAttack() {
return objAttackable;
}
int[] Location = new int[] {xLoc, yLoc};
public int[] getLocation() {
return Location;
}
public boolean getAttackable() {
return objAttackable;
}
public int getStrength() {
return objStrength;
}
public int getDefense() {
return objDefense;
}
public BufferedImage getIcon() {
return objIcon;
}
}
public BufferedImage loadImage(String iconFile) {
BufferedImage icon = null;
try {
icon = ImageIO.read(new File(iconFile));
} catch (Exception e) {
e.printStackTrace();
}
return icon;
}
}
NPCObject.java: 41: illegal start of expression
public int getDefense() {
^
NPCObject.java: 41: ';' expected
public int getDefense() {
^
NPCObject.java: 46: illegal start of expression
public BufferedImage getIcon() {
^
NPCObject.java: 46: ';' expected
public BufferedImage getIcon() {
I feel that this is probably a simple fix but I can't seem to understand what to do. Thanks for your help in advance.
Comment