用户名: 密码: 免费注册 忘记密码? 网站地图 | 加入收藏 | 设为首页
首页 | 新闻 | 工具 | 系统 | 办公 | 聊天 | 多媒体 | 网页 | 运营 | 平面 | 欣赏 | 数据库 | 程序 | 服务器 | 组网
网页 | 3dmax | Ghost | Windows Xp| Dreamweaver | photoshop | Flash | office | Alexa | Css | QQ | Asp | PHP | Jsp | Access
Flash MX 2004入门 | 网站推广策略 | CorelDRAW入门 | ASP学习 | 网站建设大师功 | Word入门
  iTbulo.com > 学院 > 程序开发教程 > JSP教程 > Jsp开发技巧 > 文章正文
java接口用法学习----------------java菜鸟学飞第一步
iTbulo.COM 2005-4-13 佚名()
jcreator pro 2.5
jdk 1.4.2
===================================
/*
* @(#)ClsUsage.java 1.0 04/12/25
*
* You can modify the template of this file in the
* directory ..\JCreator\Templates\Template_1\Project_Name.java
*
* You can also create your own project template by making a new
* folder in the directory ..\JCreator\Template\. Use the other
* templates as examples.
*
*/
package myprojects.clsusage;
import java.util.*;
class ClsUsage {

public ClsUsage() {

}

public static void main(String args[]) {
System.out.println("Starting ClsUsage...");
ISplitPage isp=new userPage(12);
isp.firstPage();
while(isp.hasPages())
{
isp.nextPage();
}

}
}
interface ISplitPage
{
void firstPage();
void nextPage();
boolean hasPages();
}
class dateObj
{
private String name;
private int age;
private boolean sex;
private int id;
public static int personID;
static
{
personID=1000;
}
public dateObj(String na,int ag,boolean sx)
{
name=na;age=ag;sex=sx;
id=dateObj.personID++;
}
public dateObj(String na,int ag)
{
name=na;age=ag;sex=true;
id=dateObj.personID++;
}
public int getId()
{
return id;
}
public String getName()
{
return name;
}
public void setName(String na)
{
name=na;
}
public int getAge()
{
return age;
}
public void setAge(int dg)
{
age=dg;
}
public boolean isSex()
{
return this.sex;
}
public void setSex(boolean sx)
{
sex=sx;
}
public String toString()
{
return ""+id+"-"+name+"-"+age+"-"+sex;
}
}
class userPage implements ISplitPage
{
// which can be accessed with itself or son
//与自身或子类所在的包无关
protected int pageCount;
protected int pageIndex;
protected java.util.Vector list;
public userPage(int pages)
{
if(pages<=0)
this.pageCount=10;
int age=20;
boolean sex=false;
list=new Vector();
for(int i=0;i<pages;i++)
{
String na=""+i+"";
dateObj ob=new dateObj(na,age+i,sex);
sex=!sex;
list.addElement(ob);
}
this.pageCount=pages;
this.pageIndex=1;
}
public void firstPage()
{
pageIndex=1;
dateObj ob=(dateObj)list.get(pageIndex-1);
System.out.println("第一页"+ob.toString());
}
public void nextPage()
{
pageIndex++;
if (pageIndex<=this.pageCount)
{
dateObj ob=(dateObj)list.get(pageIndex-1);
System.out.println("第"+pageIndex+"页"+ob.toString());
}

}
public boolean hasPages()
{
return pageIndex<=pageCount;
}
}



文章搜索
相关资讯
相关文章 相关下载
Jan Borchies家居设计(3)
Jan Borchies家居设计(2)
Jan Borchies家居设计(1)
Enric Jardi 封面设计
名杀毒软件AVP把3721列为病毒 [图]
焦点信息