• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: 小 中 大 | 推荐给好友 上一篇 | 下一篇

java接口用法学习----------------java菜鸟学飞第一步

发布: 2007-7-04 13:34 | 作者: admin | 来源:  网友评论 | 查看: 28次 | 进入软件测试论坛讨论

领测软件测试网 /*
* @(#)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;
}
}


延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:[email protected] 电话:010-51297073

软件测试 | 领测国际 | ISTQB | ISTQB官网 | TMMi | TMMi认证 | 国际软件测试工程师认证 | 领测软件测试网