Untitled
unknown
java
3 years ago
1.0 kB
6
Indexable
package com.comp301.a02adventure;
public class MapImpl implements Map {
private final int width;
private final int height;
private final int numItems;
public MapImpl(int width, int height, int numItems) throws IllegalArgumentException {
this.width = width;
if (this.width <= 0) {
throw new IllegalArgumentException("Width less than 0");
}
this.height = height;
if (this.height <= 0) {
throw new IllegalArgumentException("Height less than 0");
}
this.numItems = numItems;
}
@Override
public int getWidth() {
return width;
}
@Override
public int getHeight() {
return height;
}
@Override
public Cell getCell(int x, int y) {
return new CellImpl(x, y);
}
@Override
public Cell getCell(Position position) {
return new CellImpl(position.getX(), position.getY());
}
@Override
public void initCell(int x, int y) {}
@Override
public int getNumItems() {
return numItems;
}
}
Editor is loading...