Inventory Grundmethoden

master
GammelJan 6 years ago
parent 8a8064d4b0
commit 965c815f1f

@ -0,0 +1,37 @@
package com.dungeoncrawler;
public class Inventory {
Item items[][];
Inventory(int width, int height){
items = new Item[width][height];
}
public void addItem(Item i)
{
for(int n = 0; n <= items.length; n++){
for(int m = 0; m <= items[0].length; m++){
if(items[n][m] == null){
items[n][m] = i;
n = items.length + 1;
break;
}
}
}
}
public void dropItem(int x, int y){
items[x][y] = null;
}
public Item getItem(int x, int y){
return items[x][y];
}
}

@ -1,12 +1,12 @@
/* /*
* To change this license header, choose License Headers in Project Properties. * To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates * To change this template file, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */
package com.dungeoncrawler; package com.dungeoncrawler;
import com.dungeoncrawler.items.*; //import com.dungeoncrawler.items.*;
class Item{}
/** /**
* *
* @author jonathan * @author jonathan

Loading…
Cancel
Save