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

📄 messtype.java

📁 IO流的项目好
💻 JAVA
字号:
//信息格式
package myQQ;

import java.io.*;
import java.util.*;
 
class MessType implements Serializable
{
	String Sendid; //发送方号码
	String Sendpw; //发送方密码
	String Pro;	//省
	String City;//市
	String SendName;//发送方昵称
	String SendPw;//发送密码
	String SendSex;//发送性别
	int SendAge;//年龄
	String SendHead; //头像
	String Readid; //接受方号码
	String Content; //发送内容
	String Scene; //发送场景
	String Results; //返回结果
	Vector Friend; //好友列表
	Vector RegPro; //省集合
	Vector RegCity; //市集合
	int State = 0; //状态
	/*
	 * 0--上线   2--隐身  3--离开  -1--下线
	 * 20--返回上线信息
	 * 10--发送消息  11--发送场景
	 * 4---注册
	 * 41----省信息  42----市信息
	 */
	boolean HaseSend=false; //是否发送
	Calendar SendTime; //发送时间
	
	MessType(String Sendid, String SendName,String SendPw,
			int SendAge,String SendSex,String Pro,String City,String Head)
	{
		//注册信息
		this.Sendid = Sendid;
		this.SendName = SendName;
		this.Sendpw = SendPw;
		this.SendAge = SendAge;
		this.SendSex = SendSex;
		this.Pro = Pro;
		this.City = City;
		this.SendHead = Head;
		this.State = 4;
	}
	
	MessType(String sid,String rid,String text,Calendar time,int state)
	{	//用于发送信息的构造函数
		this.Sendid = sid;
		this.Readid = rid;
		this.SendTime = time;
		this.State = state;
		if(State==10)
			this.Content = text;
		if(State==11)
			this.Scene = text;
	}
	
	MessType(String sid,Calendar time,int state)
	{	//用于状态更改的构造函数
		this.Sendid = sid;
		this.SendTime = time;
		this.State = state;
	}
	
	MessType(String id,String pw,int state)
	{	//登录信息
		this.Sendid = id;
		this.Sendpw = pw;
		this.State = state;
	}
	
	MessType(String x,int state)
	{	//返回结果+请求省市信息
		this.State = state;
		switch (this.State) {
	    	case 0: 
	    		this.Results = x; break;
	    	case 20: 
	    		this.Results = x; break;
	    	case 41: 
	    		this.Sendid = x; break;	
	    	case 42: 
	    		this.Sendid = x; break;	
	    	case 4: 
	    		this.Sendid = x; break;
	    	
	    }
	}
	
	MessType(Vector v,int state)
	{	//返回好友列表+返回省市
		this.State = state;
		switch (this.State) {
	    	case 0: this.Friend = v; break;
	    	case 41: this.RegPro = v; break;
	    	case 42: this.RegCity = v; break;
	    }
	}
	
	public void setHaseSend(boolean hs)
	{	//更改是否发送的状态
		this.HaseSend = hs;
	}
	
	public String getChatInfo()
	{	//获得聊天信息的基本内容--用于服务器
		String stime = SendTime.toString();
		String Info = "由"+Sendid+"发送给"+Readid+"\t时间:"+stime+"\n内容为:";
		if(State==10)
			Info += Content;
		if(State==11)
			Info += Scene;
		return Info;
	}
	
	public String getStateInfo()
	{	//获得状态信息的基本内容--用于服务器
		String Info = Sendid;
		String[] s = {"上线了!","隐身了!","离开了!","下线了!"};
		switch (State) {
	    	case 0: Info += s[0]+"\n"; break;
	    	case 2: Info += s[1]+"\n"; break;
	    	case 3: Info += s[2]+"\n"; break;
	    	case -1: Info += s[3]+"\n"; break;
	    }
	    /*if(HaseSend)
	    	Info += "已发送\n";
	    else
	    	Info += "未发送\n";*/
	    return Info;
	}
}

⌨️ 快捷键说明

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