request: receipe/materials approach? and/or design pattern?

I have the annoying game on my mobile that I hate but strangely keep playing to pass the time… (it’s called brave frontier)

A part of it involves the collecting of materials as part of a crafting mini-game.

I’ve been thinking about writing a small app where I simply enter the materials I have and the app calculates what items I can craft (via recipies)

The problem thought is that these items can then become materials for other items and so forth, so there is an element of recursion going on.

I initially thought that I could used Java’s TreeNode’s but I’m not so sure anymore.

Any ideas/comments/suggestions on how to tackle this?

Can recipes output more than one item or always just one?

Just one.

I’m starting to think that a plain HashMap object might be all I that need…

public enum Material {
 ItemA, ItemB, ItemC, ItemD

public enum Item {

import java.util.HashMap;

public class CraftCheck {
  private HashMap materials = new HashMap();
  private HashMap items = new HashMap();

  public CraftCheck() {

  private void sizes() {
    System.out.println("materials.size(" + materials.size() + ")");
    System.out.println("items.size(" + items.size() + ")");

  // add inventory here
  private void inv() {
    addMaterials(Material.ItemA, 10);
    addMaterials(Material.ItemB, 8);
    addMaterials(Material.ItemC, 15);

  // util method to load hashmap
  private void addMaterials(Material material, int amount) {
    materials.put(material, amount);

  private void check() {

  private void isCraftable(Item item) {
    if(Item.MagicSword.equals(item)) {

  private void tryMagicSword() {
    if((Integer)materials.get(Material.ItemA) > 5) {
      if((Integer)materials.get(Material.ItemB) > 3) {
        System.out.println("You can make a magic sword!");


  public static void main(String[] args) {
    new CraftCheck();