国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

java 多態與抽象工廠-----------菜鳥學飛第二步

2019-11-18 14:39:03
字體:
來源:轉載
供稿:網友

  win2000 AdvSer
JCreator PRo 2.5
JDK 1.4.2
================================
/*
* @(#)ClsDyna.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.clsdyna;
import java.util.*;

class ClsDyna {

public ClsDyna() {

}

public static void main(String args[]) {
System.out.println("Starting ClsDyna...");
person pr=new boy("萬青");
person pg=new girl("李敏");
System.out.println(pr.toString());
System.out.println(pg.toString());
System.out.println("==========");
personFactory pc=new personFactory("吳波",true,33);
person tc=pc.GetPerson();
System.out.println(tc.getName());
System.out.println(tc.toString());


}
}
abstract class person
{
protected String name;
protected boolean sex;
protected int age;
protected int id;
private static int pid;
static {
pid=1000;
}
public static int PersonID()
{
return pid++;
}
public person(String na,boolean sx,int ag)
{
/*
//it also can write like this
name=na;sex=sx;
age=ag;
id=person.PersonID();

*/
this(na,ag);
if(!sx)
this.setSex(false);



}
public person(String na,int ag)
{
name=na;age=ag;sex=true;//this(na);
id=person.PersonID();
}
public person(String na)
{
name=na;age=18;sex=true;
id=person.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 sex;
}
protected void setSex(boolean sx)
{
sex=sx;
}
public String toString()
{
return "ID:"+id+";Name:"+name+";Age:"+age+";Sex:"+ (sex?"男":"女");

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 福州市| 塘沽区| 台北县| 宜君县| 武胜县| 肥东县| 新化县| 通城县| 卢氏县| 新和县| 通州市| 卢氏县| 忻城县| 双峰县| 祁阳县| 雅江县| 乌拉特前旗| 佛坪县| 永福县| 昔阳县| 灵川县| 定州市| 永春县| 湛江市| 临泽县| 沙湾县| 法库县| 三原县| 凤翔县| 田阳县| 高淳县| 滦平县| 汉寿县| 荃湾区| 黔江区| 中西区| 任丘市| 石屏县| 嘉义县| 崇明县| 怀仁县|