博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
amazon 设计 2 Furniture
阅读量:6518 次
发布时间:2019-06-24

本文共 2548 字,大约阅读时间需要 8 分钟。

public interface Furniture {    public void stressTest();    public void fireTest();}public abstract class Chair implements Furniture {public abstract String chairType();}public abstract class Table implements Furniture { public abstract String tableType();}public class MetalChair extends Chair {    @Override    public void stressTest() {        //To change body of implemented methods use File | Settings | File Templates.    }    @Override    public void fireTest() {        //To change body of implemented methods use File | Settings | File Templates.    }}public class MetalTable extends Table {    @Override    public void stressTest() {        System.out.println("Passed Stress Test");        //To change body of implemented methods use File | Settings | File Templates.    }    @Override    public void fireTest() {        //To change body of implemented methods use File | Settings | File Templates.        System.out.println("Passed Fire Test");    }    @Override    public String tableType() {        //To change body of implemented methods use File | Settings | File Templates.        String s = "This is a metal Table";        return s;    }}public class WoodenTable extends Table {    @Override    public void stressTest() {        //To change body of implemented methods use File | Settings | File Templates.        System.out.println("Failed Stress Test");    }    @Override    public void fireTest() {        //To change body of implemented methods use File | Settings | File Templates.        System.out.println("Failed Fire Test");    }    @Override    public String tableType() {        //To change body of implemented methods use File | Settings | File Templates.        String s = "This is a wooden Table";        return s;    }}public class WoodenChair extends Chair {    @Override    public void stressTest() {        //To change body of implemented methods use File | Settings | File Templates.    }    @Override    public void fireTest() {        //To change body of implemented methods use File | Settings | File Templates.    }}public class MainClass {    public static void main(String[] args){        Table table = null;        Scanner input =  new Scanner(System.in);        String str = input.next();        if(str.equals("wooden")){            table = new WoodenTable();        }   else if (str.equals("metal")){            table = new MetalTable();        }        System.out.println(table.tableType());        table.stressTest();        table.fireTest();    }}

 

转载于:https://www.cnblogs.com/leetcode/p/3864612.html

你可能感兴趣的文章
TP5+PHPexcel导入xls,xlsx文件读取数据
查看>>
五花八门的计算机语言
查看>>
基于Yum安装zabbix3.0
查看>>
Web开发(进阶)- Django【进阶篇】
查看>>
Master-work模式
查看>>
5.7. 保护 Sendmail 的安全
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
Vmware Vcenter6.0 全新安装及群集配置介绍
查看>>
我的友情链接
查看>>
stomp-php
查看>>
Mysql慢查询日志脚本
查看>>
python字典生成式
查看>>
WampServer下Apache配置vHost
查看>>
IOS 开发证书设置
查看>>
poj1328 -贪心雷达问题
查看>>
我的友情链接
查看>>
第柒章學習 Lisp 3rd Edition, Winston & Horn
查看>>
簡單使用 tshark 命令形的 wireshark tcpdump
查看>>
git 常用指令快速上手
查看>>