Java Interface Usage Learning----------------Java Rookie learn to fly the first step
Last Update:2017-02-28
Source: Internet
Author: User
/*
* @ (#) Clsusage.java 1.0 04/12/25
*
* Can modify the template of this file in the
* directory. \jcreator\templates\template_1\project_name.java
*
* 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 is accessed with itself or son
//Is independent of the package in which it or subclasses are located
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 ("first page" +ob.tostring ());
}
public void NextPage ()
{
pageindex++;
if (pageindex<=this.pagecount)
{
Dateobj ob= (dateobj) list.get (pageIndex-1);
System.out.println ("+pageindex+", "page" +ob.tostring);
}
}
public boolean haspages ()
{
return pageindex<=pagecount;
}
}