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

📄 player.java

📁 局域网斗地主框架,好象没有card的功能不能打牌
💻 JAVA
字号:
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;

/*
 * 创建日期 2005-7-22
 *
 * TODO 要更改此生成的文件的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */

/**
 * @author 叶少伟 TODO 要更改此生成的类型注释的模板,请转至 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
public class Player implements Serializable
{
	private Properties			settings;
	private FileOutputStream	setOutFile;

	public Player(Player p)
	{
		if(p == null)
			init("Player");
		else
			init(p.getName());
	}

	public void init(String name)
	{
		try
		{
			this.settings = new Properties();
			FileInputStream setInFile = new FileInputStream(name + ".txt");
			this.settings.load(setInFile);
			setInFile.close();
		}
		catch(FileNotFoundException e)
		{
			// TODO 自动生成 catch 块
//			e.printStackTrace();
			try
			{
				this.settings.setProperty("name", "Player1");
				this.settings.setProperty("score", "0");
				this.settings.setProperty("winTime", "0");
				this.settings.setProperty("lossTime", "0");
				this.settings.setProperty("sip", InetAddress.getLocalHost()
						.getHostAddress());
				this.settings.setProperty("cip", InetAddress.getLocalHost()
						.getHostAddress());
				this.settings.setProperty("port", "5206");
				this.setOutFile = new FileOutputStream("Player.txt");
				this.settings.store(this.setOutFile, "Player information:");
				setOutFile.close();
			}
			catch(FileNotFoundException e1)
			{
				// TODO 自动生成 catch 块
				e1.printStackTrace();
			}
			catch(IOException e1)
			{
				e1.printStackTrace();
			}
		}
		catch(UnknownHostException e)
		{
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		catch(IOException e)
		{
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
	}

	public void setSetting(Properties set)
	{
		this.settings=set;
	}
	
	public String getSIp()
	{
		return this.settings.getProperty("sip");
	}

	public String getCIp()
	{
		return this.settings.getProperty("cip");
	}

	public int getPort()
	{
		return Integer.parseInt(this.settings.getProperty("port"));
	}

	public String getName()
	{
		return this.settings.getProperty("name");
	}
	
	public String getWinTime()
	{
		return this.settings.getProperty("winTime");
	}
	
	public String getScore()
	{
		return this.settings.getProperty("score");
	}
	
	public String getLossTime()
	{
		return this.settings.getProperty("lossTime");
	}
}

⌨️ 快捷键说明

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