// 细化抽象类,定义一个由km到其他单位的转换器package Bridge_Pattern;public class RefinedAbstract extends Abstraction {RefinedAbstract(Implementor implementor) {this.implementor = implementor;}// 输出目标单位所对应的长度public double output() {double output = 0;switch (implementor.getType()) {case "km":output = implementor.getInput();break;case "mi":output = implementor.getInput() * 1.852;break;case "nmi":output = implementor.getInput() * 1.609344;break;case "ly":output = implementor.getInput() * 1.7011e-13;break;default:output = implementor.getInput();break;}return output;}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。