⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 room.java

📁 简单的一个maze系统
💻 JAVA
字号:
package mazeImplementation;// -----------------------------------------------// Programming 2 -- Semester 2, 2007// Maze Engine implementation// Peter Tilmanis, 8 August 2007// -----------------------------------------------// Room class// -----------------------------------------------import java.util.*;public class Room{   private MazeRef location;   private String name;   private List<Item> items;   private List<ExitPoint> exits;   public Room()   {      this(new MazeRef(), "Generic Room");   }   public Room(MazeRef location, String name)   {      this.location = location;      this.name = name;      this.items = new Vector<Item>();      this.exits = new Vector<ExitPoint>();   }   public MazeRef getLocation()   {      return location;   }   public String getName()   {      return name;   }   public void addExit(ExitPoint in)   {      exits.add(in);   }     public ExitPoint getExit(String name)   {      for (int i = 0; i < exits.size(); i++)      {         ExitPoint temp = exits.get(i);         if ( temp.getName().equals(name) )         {            return temp;         }      }      return null;   }   public boolean removeExit(String exitName)   {      for (int i = 0; i < exits.size(); i++)      {         ExitPoint temp = exits.get(i);         if ( temp.getName().equals(exitName) )         {            exits.remove(i);            return true;         }      }      return false;   }   public void addItem(Item item)   {      items.add(item);      Collections.<Item>sort(items);   }     public Item getItem(String name)   {      for (int i = 0; i < items.size(); i++)      {         Item temp = items.get(i);         if ( temp.getName().equals(name) )         {            return temp;         }      }      return null;   }   public boolean removeItem(String itemName)   {      for (int i = 0; i < items.size(); i++)      {         Item temp = items.get(i);         if ( temp.getName().equals(itemName) )         {            items.remove(i);            return true;         }      }      return false;   }   public Item[] getItemList()   {      return items.toArray(new Item[0]);   }   public ExitPoint[] getExitList()   {      return exits.toArray(new ExitPoint[0]);   }   public String toString()   {      String result = location + ":" + name + ":";      Item[] items = this.getItemList();      for (int i = 0; i < items.length; i++)      {         result += items[i].getName();         if (i != items.length-1)            result += ",";      }      result += ":";      ExitPoint[] exits = this.getExitList();      for (int i = 0; i < exits.length; i++)      {         result += exits[i].getName();         if (i != exits.length-1)            result += ",";      }      return result;   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -