| 
 
| 本帖最后由 wudiisss 于 2011-11-14 09:38 编辑 
 请问下面这个程序算是面向接口编程吗?突然想起来的一个设计模式,然后就写了一段代码,自己也不太确定算不算,
 
 package students;
 import java.math.*;
 public class Test {
 public static void main(String [] args){
 Thing a=new Stone();
 a.throwThing(20,12);
 }
 }
 class Stone implements Thing{
 public void throwThing(double vv,double hh){
 double dis=Math.sqrt(vv*2*hh/10);
 System.out.println("石头"+dis);
 }
 }
 class Paper implements Thing{
 public void throwThing(double vv,double hh){
 double dis=Math.sqrt(vv*2*hh/10);
 System.out.println("纸团"+dis);
 }
 }
 
 //接口是
 public interface Thing{
 public void throwThing(double a,double b);
 }
 | 
 |