{:2_32:}
public interface BlankInterface {
public static final int count=1000;
public void sendmoney();
}
public interface BlankInterface1 extends BlankInterface {
void interBlank();
}
public class BlankDemo {
private String name;
private String location;
private int id;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public BlankDemo() {
}
public BlankDemo(String name, String location, int id) {
super();
this.name = name;
this.location = location;
this.id = id;
}
public void drawMoney(){
System.out.println("父类我有取钱的功能 ");
}
public void saveMoney(){
System.out.println("父类我有存钱的功能 ");
}
}
public class BlankMain {
public static void main(String[] args) {
ConstructBlank blank = new ConstructBlank("转账", "建设银行", "北京市海淀区", 1);
System.out.println("我的特有功能是:" + blank.getTransfercount() + "我的名字是:"
+ blank.getName() + "我的位置是:" + blank.getName() + "我的编号是:"
+ blank.getId());
// blank.drawMoney();
function(new ConstructBlank());
BlankInterface inter=new ConstructBlank();
inter.sendmoney();
}
public static void function(BlankDemo blank){
if(blank instanceof ConstructBlank){
ConstructBlank b=(ConstructBlank)blank;
b.getMony();
b.drawMoney();
b.interBlank();
b.saveMoney();
b.sendmoney();
}
}
}
public abstract class Abstractblank {
private String name;
private int department;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getDepartment() {
return department;
}
public void setDepartment(int department) {
this.department = department;
}
public Abstractblank() {
}
public Abstractblank(String name, int department) {
this.name = name;
this.department = department;
}
public abstract void saveMoney();
public abstract void sendMoney();
}
public class AbstractBlankDemo extends Abstractblank {
public AbstractBlankDemo() {
}
public AbstractBlankDemo(String name, int department) {
super(name,department);//调用父类的构造函数
}
public void saveMoney(){
System.out.println("我的名字是"+this.getName()+"我的部门号是:"+this.getDepartment());
}
public void sendMoney(){
System.out.println("欢迎到我家来存钱");
}
}
public class AbstractBlankMain {
public static void main(String[] args) {
AbstractBlankDemo demo=new AbstractBlankDemo("中国工商银行",1023);
demo.saveMoney();
demo.sendMoney();
Abstractblank blank=new AbstractBlankDemo();//多态
blank.setName("中国农业银行");
blank.setDepartment(1034);
System.out.println(blank.getName()+"...."+blank.getDepartment());
}
}
|
|