可以帮我分析下JAVA问题么??

来源:百度知道 编辑:UC知道 时间:2024/06/12 20:30:43

长宽高 颜色, 型号 重量

木门
材料 开的时候有响声, 不防盗

铁门,
开的时候没声音, 防盗.

防盗门.
开的时候没声音, 防盗 有猫眼, 有上下锁,

需要有 继承, 接口, 多态, 抽象类等方式

请帮我分析下 哪个应该是接口里 哪个抽象类 谁去继承 谁去实现
main方法在都有什么? 请高手耐心指导?
就是用这些信息来编写一段代码。。。用到继承, 接口, 多态, 抽象类等方式 !

如果接口抽象类都要用到的话,我推荐的做法如下:
门是一个抽象类,下面分别有3个子类去继承这个门的抽象类.即继承父类的属性.

//新建一个抽象类Door
public abstract class Door
{
//门的属性定义
protect int length;
protect int width;
protect int height;
protect String color;
protect int weight;
protect String type;
//默认构造方法
public Door()
{
}
//重载构造方法
public Door(int len,int wid,int hei,String col,int wei,String type)
{
this.length = len;
this.width = wid;
this.height = hei;
this.color = col;
this.weight = wei;
this.type = type;
//显示结果
System.out.println("长"+this.length+"宽"+this.width+"高"+this.height+"颜色"+this.color+"重量"+this.weight+"型号"+this.type);
}
}

新建一个接口定义如下:
public interface Idoor
{
//开门是否有声音
public void openDoor();
//是否防盗
public void isSafe();
}

然后就可以开始编写继承和实现的