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

📄 coin.java

📁 liu7788414
💻 JAVA
字号:
package staticdata;

/**
 * <p>Title: Reader.java</p>
 * <p>Description: read and convert xml file</p>
 * <p>Copyright: Gameloft 2004</p>
 * <p>Company: Gameloft Shanghai</p>
 * @author Yi Wen Hu
 * @version 1.0
 */


import javax.xml.parsers.*;
import org.w3c.dom.*;

import java.util.Vector;
import java.io.*;

public class Coin {
  private int m_id;

//  private int m_property;
  private int m_type;
  private int m_info;
  private int m_posX;
  private int m_posY;


  public Coin(Element e) {
    m_id = Integer.valueOf(e.getAttribute(Reader.XML_COIN_ID)).intValue();

    m_type = Reader.getIndexOfString(e.getAttribute(Reader.XML_COIN_TYPE),
                                     Reader.XML_COIN_TYPE_VALUE);

    String st=e.getAttribute(Reader.XML_COIN_INFO);
    if(st.trim().length() ==0)
      m_info=-1;
    else
      m_info = Integer.valueOf(st).intValue();

    st=e.getAttribute(Reader.XML_COIN_POSITION);
    String [] sta=st.split(",");
    m_posX = Integer.valueOf(sta[0]).intValue();
    m_posY = Integer.valueOf(sta[1]).intValue();

  }

  public void save(FileOutputStream fos) {
    int count;
    byte[] data;
    try {
      // property
      fos.write( (byte) m_id);
      fos.write( (byte) m_type);
      fos.write( (byte) m_info);
      Reader.WriteShort((short)m_posX,fos);
      Reader.WriteShort((short)m_posY,fos);

    }
    catch (Exception e) {
      e.printStackTrace();
    }

  }

  public void test() {
    System.out.print("COIN:");
    System.out.print("m_id=" + m_id);
    System.out.print(",m_type=" + m_type);
    System.out.print(",m_info=" + m_info);
    System.out.println(",m_pos:" + m_posX+","+m_posY);

  }

}


⌨️ 快捷键说明

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